[Rd] Splus/R typedef for C equivalent of S "integer"
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Jun 4 21:48:47 CEST 2008
R's R.h already has
typedef double Sfloat;
typedef int Sint;
#define SINT_MAX INT_MAX
#define SINT_MIN INT_MIN
for this purpose, and it is used in a lot of packages.
It goes back a long way, and I don't remember its origins but 'S
Programming' is one source.
On Wed, 4 Jun 2008, Bill Dunlap wrote:
> We've been working on making it easier to write
> packages that work in both R and Splus. One issue
> is that R and Splus use different internal representations
> of integers and this makes a difference on their 64-bit
> versions: R uses ints (32 bits on 32-bit and 64-bit versions
> of R) and Splus uses longs (32 bits on 32-bit Splus and
> 64 bits on 64-bit Splus). The obvious ways to deal with
> the difference are to use a typedef or a #define to map
> those to a common name. I think it would be handy to
> put this definition into R.h or some other R header file
> (Splus now has an R.h and other header files with the R
> names that we recommend for all package work.)
> Should this be a typedef or a #define? What should its
> name be?
> There is a file, RSCommon.h (from omegahat?), that I've seen
> in a few packages which uses a typedef, RSInt, for this.
> Repeated typedefs, even with the same definition, are illegal
> so putting typedef ... RSInt into R.h would break those packages.
> (C doesn't yet have an if-typedef-exists or untypedef construct,
> does it?)
> I like XXXinteger, since it refers to the R/Splus name of
> the class, "integer", instead of the C-like name. Should
> the "XXX" prefix be "RS" or "RSplus" or "S"?
> I like typedefs since you can use them in the debugger.
> Should a typedef be accompanied by a #define XXXinteger_defined
> so one can write code that works on older versions of R or
> Splus without the typedef?
> I think R.h would be a good place for it, but I don't
> have strong feeling about that one.
> If we can come to a consensus on the name, typedef/#define,
> and which *.h file, I can put it into Splus.
> Bill Dunlap
> Insightful Corporation
> bill at insightful dot com
> "All statements in this message represent the opinions of the author and do
> not necessarily reflect Insightful Corporation policy or position."
> R-devel at r-project.org mailing list
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