Re: [Rd] PROTECT and OCaml GC.

From: Guillaume Yziquel <guillaume.yziquel_at_citycable.ch>
Date: Wed, 02 Dec 2009 02:32:55 +0100

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/

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 02 Dec 2009 - 01:34:11 GMT

This archive was generated by hypermail 2.2.0 : Wed 02 Dec 2009 - 02:40:55 GMT