[Rd] R_MakeExternalPtr

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Oct 24 11:02:11 CEST 2005


On Mon, 24 Oct 2005, TB wrote:

> Brian,
>
> Prof Brian Ripley <mailto:ripley at stats.ox.ac.uk> wrote:
>> This is one of those undocumented things (AFAIK): LENGTH applies only
>> to 'vectors'.  So don't use t and definitely don't set it for others.
>> The macro expands to
>>
>> #define LENGTH(x)       (((VECSEXP) (x))->vecsxp.length)
>>
>> What is a vector here?  Something which gets actually allocated by
>> allocVector() AFAICS, that is an atomic or generic vector or an
>> expression.  OTOH, an EXTPTRSXP is stored in a cons cell.
>>
>> There is also a function length(), which is safer.
>
> Thanks for your message. Things are much clearer now to me.
>
> Can I safely assume that INTSXP, REALSXP, LGLSXP, STRSXP, CPLXSXP and VECSXP
> are
> vectors (while EXTPTRSXP is not).

Yes. RAWSXP and EXPRSXP are also vectors (and so in a sense is CHARSXP).

Brian

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list