[Rd] Re: [R] Is k equivalent to k:k ?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 10 14:55:01 CET 2004


On Fri, 10 Dec 2004, Martin Maechler wrote:

> I'm diverting to R-devel,  where this is really more
> appropriate.
>
> In the future, we really might want to have a new type,
> some "long integer" or "index" which would be used both in R
> and C's R-API for indexing into large objects where 32-bit
> integers overflow.
> I assume, we will keep the    R "integer" == C "int" == 32-bit int
> forever, but need something with more bits rather sooner than later.
> But in any, case by then, some things might have to change in
> R (and C's R-API) storage type of indexing.

Indeed.  Assuming that seq() will always produce one type to pass to C 
code is dangerous.  Not so long ago someone asked why an R call had 
as.integer around a length, as ?length says the result is integer.
I replied that

1) This was liable to change and
2) Methods for generic functions were not forced to return the same thing 
as the documentation for the default method.

We are compelled to keep R "integer" == C "int" == Fortran "integer" as 
32-bit by backwards compatibility, as that is what all known 64-bit 
platforms do and hence what external libraries (notably libm/libc and 
Fortran support libraries) use.  This limits the length of R vectors to 
2^31-1, and that will start to bite fairly soon.  We do already have 
people using larger objects (as measured in bytes), and for example the 
return type of object.size got changed from int to double to accommodate 
such.  The C code has a type R_len_t that will eventually be used for
index and length computations, at least in C code.  The widespread use of 
Fortran for e.g. matrix computations limits what we can do.

Note that this was until recently only an issue for 64-bit operating 
systems, as the 32-bit OS 4Gb limit on a block of memory bites first 
except for raw vectors.

-- 
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