Skip to content
Back to formatted view

Raw Message

Message-ID: <4B15C3C7.5010809@citycable.ch>
Date: 2009-12-02T01:32:55Z
From: Guillaume Yziquel
Subject: PROTECT and OCaml GC.
In-Reply-To: <0A1D8E9D-0BD6-40F7-B98C-59075CE04E49@r-project.org>

Simon Urbanek a ?crit :
> 
> You just pass it as value of the call. I suspect the reason it doesn't 
> work is in your code, not in the facility (note that the link above is 
> useless since the construction is mystery - if you were constructing it 
> right, it would work ;)).
> 
> Small example:
> 
> SEXP myEval(SEXP FN, SEXP first_arg) {
>   return eval(LCONS(FN, CONS(first_arg, R_NilValue)), R_GlobalEnv);
> }
> 
> ... or reading R-ext:
> 
> "There are a series of small macros/functions to help construct 
> pairlists and language objects (whose internal structures just differ by 
> SEXPTYPE. Function CONS(u, v) is the basic building block: is constructs 
> a pairlist from u followed by v (which is a pairlist or R_NilValue). 
> LCONS is a variant that constructs a language object. Functions list1 to 
> list4 construct a pairlist from one to four items, andlang1 to lang4 do 
> the same for a language object (a function to call plus zero to three 
> arguments). Function elt and lastElt find the ith element and the last 
> element of a pairlist, and nthcdr returns a pointer to the nth position 
> in the pairlist (whose CAR is the nth item)."

Reading R-exts,

-1- I believe it would be a good idea to put an example with CONS and 
LCONS in section 5.11.

-2- Building a LANGSXP list with tags from arguments needs invocations 
of CONS LCONS SET_TAG and install. While this is not exactly to my 
taste, using install is really not to my taste since it checks the 
symbol table and eventually creates a symbol. Isn't there a way to 
create a tag without using install over and over? A macro that simply 
sets the tag to whatever CHARSXP might be useful?

-- 
      Guillaume Yziquel
http://yziquel.homelinux.org/