Skip to content

Dynamic list creation (SEXP in C) returns error "unimplemented type (29) in 'duplicate'" Dynamic list creation (SEXP in C) returns error

3 messages · Radford Neal, George Vega Yon

#
"changing its size using SETLENGTH (Rf_lengthgets)"

NO! NO! NO!  SETLENGTH does not do the same thing as Rf_lengthgets.
You should never use SETLENGTH, which is not part of the API, and
really should not even exist.

For that matter Rf_lengthgets is also not part of the API.  I
recommend getting the length right to start with.

   Radford Neal
#
On Wed, Nov 06, 2013 at 02:40:59PM -0300, George Vega Yon wrote:
Is SET_LENGTH a documented feature of the API?  Not that I can see.

However, it is indeed different from SETLENGTH.  Perhaps your problem
is in the following code you posted:

  REPROTECT(SET_LENGTH(id,    length(lambda) + z), ipx0);
  REPROTECT(SET_LENGTH(lambda,length(lambda) + z), ipx1);

It looks like the first line should have length(id), not length(lambda).

Your usage of REPROTECT and duplicate seems odd.  If you make the
stuff you allocate part of your original list as soon as you allocate
it, you only need to protect the original list.  And it's not clear
why you think you need to duplicate vectors.

   Radford Neal