[Rd] type of list elements in .Call
Huntsinger, Reid
reid_huntsinger at merck.com
Mon Jan 31 18:42:05 CET 2005
This just means that R doesn't currently do anything complicated when you
ask for a pointer to the data in an R vector object. But that doesn't
matter; the behavior of REAL etc doesn't depend on that.
Note that INTEGER, REAL, etc just give you pointers of type int *, double *,
etc. It's up to you to make sure that a particular use makes sense or you'll
get garbage at best. As discussed in the manual, you can either do this on
the R side, or in C: first check the type of the object, then coerce if that
makes sense and is necessary, and handle errors as you see fit.
Coercion between types requires a copy, in general, so you need to
explicitly ask for that.
Reid Huntsinger
-----Original Message-----
From: r-devel-bounces at stat.math.ethz.ch
[mailto:r-devel-bounces at stat.math.ethz.ch] On Behalf Of Faheem Mitha
Sent: Monday, January 31, 2005 10:52 AM
To: Prof Brian Ripley
Cc: r-devel at stat.math.ethz.ch
Subject: Re: [Rd] type of list elements in .Call
On Mon, 31 Jan 2005, Prof Brian Ripley wrote:
> This is covered, copiously, in the examples in `Writing R Extensions'.
> Hint: search for coerceVector.
I see. I thought that INTEGER and its relatives did coercion too, but now
I see that is not stated anywhere.
Eg. REAL is first used in "Writing R Extensions" in 4.7.1 as in
REAL(ab)[0] = 123.45
...
and I cannot find a discussion about what it does previous to that, or
indeed afterwards.
In Rinternals header file, it says
/* Under the generational allocator the data for vector nodes comes
immediately after the node structure, so the data address is a
known ofset from the node SEXP. */
This does not mean much to me. Perhaps a short comment in the
documentation would be helpful, if not already present.
Faheem.
______________________________________________
R-devel at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
More information about the R-devel
mailing list