From guillaume.yziquel at citycable.ch  Thu Nov 26 02:27:08 2009
From: guillaume.yziquel at citycable.ch (Guillaume Yziquel)
Date: Thu, 26 Nov 2009 02:27:08 +0100
Subject: [Rd] Symbols, install, and eval.
Message-ID: <4B0DD96C.9060104@citycable.ch>

Hello.

I've got two values which are calls (i.e. LANGSXPs). The first one, x, 
is generated through the parser of gram.c. The second one, z, is built 
manually, by retrieving the symbols of "str" and of "lm" via the install 
function.

The structure of x and y are shown at the bottom of this email.

Evaluating x succeeds:

> # R.Raw.eval_langsxp x;;
> function (formula, data, subset, weights, na.action, method = "qr", 
>     model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, 
>     contrasts = NULL, offset, ...)  
> - : R.Raw.sexp = <abstr>
> # ml_eval x;;
> function (formula, data, subset, weights, na.action, method = "qr", 
>     model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, 
>     contrasts = NULL, offset, ...)  
> - : R.Raw.sexp = <abstr>

While evaluating z fails. (ml_eval is a an OCaml function mimicking the 
eval function of eval.c).

> # R.Raw.eval_langsxp z;;
> Erreur dans function (object, ...)  : 
>   function g?n?rique incorrecte dans 'UseMethod'
> Exception: Failure "OCaml-R error in r_eval_sxp C stub.".
> # ml_eval z;;
> Erreur : impossible de trouver la fonction "???"
> /bin/sh: line 1: 15884 Erreur de segmentation  ocaml

So I was wondering if someone could give some advice on what I am doing 
wrong when building z. Here's the structure of x (parser-generated from 
R code/string) and of z (manually constructed with 'install').

> # show x;;
> - : R.Internal.Pretty.t = CALL (ARG "str", [(NULL, ARG "lm")])
> # show z;;
> - : R.Internal.Pretty.t =
> CALL
>  (PROMISE
>    {value =
>      CLOSURE {formals = LIST [(ARG "object", PLACE); (ARG "...", PLACE)]};
>     expr =
>      CALL (SYMBOL (Some ("lazyLoadDBfetch", BUILTIN)),
>       [(NULL, INT [166954; 101]); (NULL, ARG "datafile");
>        (NULL, ARG "compressed"); (NULL, ARG "envhook")]);
>     prom_env = NULL},
>  [(NULL,
>    PROMISE
>     {value =
>       CLOSURE
>        {formals =
>          LIST
>           [(ARG "formula", PLACE); (ARG "data", PLACE); (Unknown, PLACE);
>            (ARG "weights", PLACE); (ARG "na.action", PLACE);
>            (ARG "method", STRINGS ["qr"]); (ARG "model", Unknown);
>            (ARG "x", Unknown); (ARG "y", Unknown); (Unknown, Unknown);
>            (ARG "singular.ok", Unknown); (ARG "contrasts", NULL);
>            (ARG "offset", PLACE); (ARG "...", PLACE)]};
>      expr =
>       CALL (SYMBOL (Some ("lazyLoadDBfetch", BUILTIN)),
>        [(NULL, INT [200005; 1139]); (NULL, ARG "datafile");
>         (NULL, ARG "compressed"); (NULL, ARG "envhook")]);
>      prom_env = NULL})])
> # ml_eval x;;
> function (formula, data, subset, weights, na.action, method = "qr", 
>     model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, 
>     contrasts = NULL, offset, ...)  
> - : R.Raw.sexp = <abstr>
> # ml_eval z;;
> Erreur : impossible de trouver la fonction "??J"
> /bin/sh: line 1: 26563 Erreur de segmentation  ocaml
> make: *** [test-ocaml-r] Erreur 139

All the best,

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



[Rd] Symbols, install, and eval.
Guillaume Yziquel