Skip to content
Prev 59919 / 63424 Next

[External] SET_COMPLEX_ELT and SET_RAW_ELT missing from Rinternals.h

Thanks!

So what would be the prescribed way of assigning elements to a CPLXSXP if I
needed to?

One way I see is to do what most of the code inside the interpreter does
and grab the vector's data pointer:

    COMPLEX(sexp)[index] = value;
    COMPLEX0(sexp)[index] = value;

This will materialize an ALTREP CPLXSXP though, so maybe the best way would
be to mirror what SET_COMPLEX_ELT does in Rinlinedfuns.h?

    if (ALTREP(sexp)) ALTCOMPLEX_SET_ELT(sexp, index, value); else
COMPLEX0(sexp)[index] = vector;

This seems better, but it's not used in the interpreter anywhere as far as
I can tell, presumably because of the setter interface not being complete,
as you point out. But should I be avoiding this second approach for some
reaosn?

k
On Tue, Jun 29, 2021 at 4:06 AM <luke-tierney at uiowa.edu> wrote: