From guillaume.yziquel at citycable.ch  Wed Dec  2 02:32:55 2009
From: guillaume.yziquel at citycable.ch (Guillaume Yziquel)
Date: Wed, 02 Dec 2009 02:32:55 +0100
Subject: [Rd] PROTECT and OCaml GC.
In-Reply-To: <0A1D8E9D-0BD6-40F7-B98C-59075CE04E49@r-project.org>
References: <4B11B75C.9070806@citycable.ch>
	<8ec76080911281625q5d5b8824hefb14af9b23d29f0@mail.gmail.com>
	<4B11C55E.2060909@citycable.ch>
	<F11B6C18-26EC-41F8-9EEB-A614D16945AC@r-project.org>
	<4B12C417.1050308@citycable.ch>
	<65D411CD-34C3-4B89-8FF0-98C9BD7613FB@r-project.org>
	<4B13FC0F.40604@citycable.ch>
	<F60B92C3-5989-404C-8FEB-1B6002824449@r-project.org>
	<4B140B7A.2080102@citycable.ch>
	<0A1D8E9D-0BD6-40F7-B98C-59075CE04E49@r-project.org>
Message-ID: <4B15C3C7.5010809@citycable.ch>

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/



[Rd] PROTECT and OCaml GC.
Guillaume Yziquel