Laurent Gautier a écrit :
> Guillaume Yziquel wrote:
>> Hi.
>>
>> I'm working on an OCaml binding for R. Namely OCaml-R.
>>
>> Could someone point me to the code in rpy which is used to force
>> promises (i.e. PROMSXP SEXPs)? That would be really helpful.
>
> http://bitbucket.org/lgautier/rpy2/src/tip/rpy/rinterface/rinterface.c#cl-3171
> line 3171-3177.
Thank you so much.
OK. So you simply eval the PROMSXP, as you would with a LANGSXP? That's
the kind of information I haven't been able to find on r-de...@... or in
the documentation.
Moreover, you consider using R_tryEval if you want to catch errors, I guess.
>> Please tell me if my post is off-topic and unwelcome.
>
> Well, you are asking implementation details. I cannot find a way to call
> this "off-topic" ;-)
Well, one never knows. It's not exactly rpy that I'm interested in, but
my own binding. So I'm taking gloves.
> Best,
>
> L.
>
> PS: I followed your recent post to r-devel with interest. I considered
> making lower level bindings at some point but postponed it to an
> unspecified release in the future (if this ever happens).
Thanks. I'm not doing low-level for the fun of it (even if I believe
that being able to natively compile R code through the OCaml compiler
would be a valuable offspring), but mostly because I find it really hard
to get documentation on the regular API. So I figured out that delving
into structures would be interesting, less time-wasting.
If you care, you can try out the Debian package on my website. It's
always the latest version of OCaml-R that compiles. I'd be interested in
any feedback, even it's simply documentation requests, or "doesn't work
for me". Moreover, I believe that using OCaml's toplevel pretty-printer
to display R values would perhaps be of interest to you. As OCaml is
more static and functional than Python, you also have in
R.Internal.Pretty module (or more precisely in the
R.Internal.PrettyTypes module-argument to the R.Internal.Parser functor)
a function called build, which could be seen as work-in-progress
specification of the structure of SEXPs.
> # t';;
> - : R.Internal.Pretty.t =
> PROMISE
> {value = SYMBOL None;
> expr =
> CALL (SYMBOL (Some ("lazyLoadDBfetch", BUILTIN)),
> [(NULL, INT [153119; 105]); (NULL, ARG "datafile");
> (NULL, ARG "compressed"); (NULL, ARG "envhook")]);
> env =
> ENV
> {frame =
> LIST
> [(ARG "this", ENV {frame = Recursive <lazy>; hashtab = NULL});
> (ARG "expr",
> CALL (SYMBOL (Some ("lazyLoadDBfetch", BUILTIN)),
> [(NULL, ARG "key"); (NULL, ARG "datafile");
> (NULL, ARG "compressed"); (NULL, ARG "envhook")]));
> (ARG "vals", NULL); (ARG "use", NULL); (ARG "envhook", Unknown);
> (ARG "envenv", ENV {frame = NULL; hashtab = Unknown});
> (ARG "i", INT [7]); (ARG "compressed", Unknown); (ARG "rvars", NULL);
> (ARG "vars", NULL); (ARG "map", NULL);
> (ARG "env", ENV {frame = NULL; hashtab = Unknown});
> (ARG "datafile", Unknown); (ARG "mapfile", NULL);
> (ARG "mkenv", Unknown); (Unknown, Unknown); (ARG "set", Unknown);
> (ARG "getFromFrame", Unknown); (ARG "existsInFrame", Unknown);
> (Unknown, Unknown); (ARG "readRDS", NULL); (ARG "glue", Unknown);
> (ARG "filebase",
> PROMISE {value = Unknown; expr = ARG "dbbase"; env = NULL});
> (ARG "envir",
> PROMISE
> {value = ENV {frame = NULL; hashtab = Unknown}; expr = ARG "ns";
> env = NULL});
> (ARG "filter",
> PROMISE
> {value = Unknown;
> expr =
> CALL (Unknown,
> [(NULL, LIST [(ARG "n", Unknown)]);
> (NULL,
> CALL (SYMBOL (Some ("!=", BUILTIN)),
> [(NULL, ARG "n"); (NULL, Unknown)]));
> (NULL, NULL)]);
> env = NULL})];
> hashtab = NULL}}
P.S.: Do you mind if I cross-post to ocaml-r-de...@?
--
Guillaume Yziquel
http://yziquel.homelinux.org/
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list