From ripley at stats.ox.ac.uk  Mon Oct 24 11:02:11 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Mon, 24 Oct 2005 10:02:11 +0100 (BST)
Subject: [Rd] R_MakeExternalPtr
In-Reply-To: <F05B338A1B21D9119FFF0004761A511301ECD7@MXS>
References: <F05B338A1B21D9119FFF0004761A511301ECD7@MXS>
Message-ID: <Pine.LNX.4.61.0510240958260.9046@gannet.stats>

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



[Rd] R_MakeExternalPtr
Prof Brian Ripley