cpp11 icon indicating copy to clipboard operation
cpp11 copied to clipboard

Should the default `SEXP` in `r_vector` be a typed vector of length 0 rather than `R_NilValue`?

Open DavisVaughan opened this issue 1 year ago • 0 comments
trafficstars

i.e. to support things like https://github.com/r-lib/cpp11/issues/315 where you default construct the vector and immediately try and put attributes on it.

Would also simplify internal code that currently has to account for the possibility of R_NilValue as data_ quite a bit.

We'd have to write our own default constructor but I think that's totally possible?


A downside of this is that the default constructor would have to allocate and would no longer be noexcept or as "cheap", but I can't see that mattering much because you eventually allocate anyways?

DavisVaughan avatar Aug 24 '24 15:08 DavisVaughan