aov

Robert Gentleman rgentlem@stat.auckland.ac.nz
Fri, 5 Jun 1998 12:21:34 +1200 (NZST)


> To continue on this approach, and follow up on these FIXMEs, I need to
> understand some of the internal functions like CAR, CDR, and
> combinations thereof.  I found the definition of CAR in
> src/include/Defn.h as:
> 
> #define CAR(e)          ((e)->u.listsxp.carval)
> 
> But where is u.listsxp.carval defined?  For that matter, where is the
> Scheme/LISP interpreter?
> Is there a roadmap? list of where the different pieces of R reside?
> 
> 

  Well there isn't a road map but there probably oughta be.
  Everything (almost) in R is a SEXPREC, and one of the mor common of these
  is the LISTSXP,
  
  it is basically a triple- the car, the cdr and the tag
  
   a list is a connected group of LISTSXP's,
    the car is a pointer to the "value" in that element of the list,
    the cdr is a pointer to the next LISTSXP (in the list)
    the tag is a place to keep things like the name associated with the
    list element.
    
    the first element of a list l is obtained by CAR(l)
    the second element by CADR(l) (CAR(CDR(l)))
    in the lisp world one cdr's down the list;
    
    the name for the first element is TAG(l)
    for the second TAG(CDR(l))
    and so on
    
    SEXPREC's (our basic building block) can be one of 20 different types,
    but they are all similar enough to be contained in one C union.
    First in the union is the info slot (32 bits), this is used for all sorts
    of nasty things
    
    then comes a slot for an SEXPREC that contains the attributes (this is 
    where the S-style attributes are stuck)
    
    then the actual data structures - notice that most of these are triples
    (vectors, primitives and environments are exceptions).
    
    hope this helps....
    robert
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._