Re: [Rd] PROTECT and OCaml GC.

From: Guillaume Yziquel <guillaume.yziquel_at_citycable.ch>
Date: Tue, 01 Dec 2009 12:58:44 +0100

Guillaume Yziquel a écrit :
> Guillaume Yziquel a écrit :

>>
>> One last thing, concerning the use of promises. If I do install, 
>> findVar, without forcing the resulting promise, and then construct the 
>> call, I get a failure:

Replacing findfun by findvar works in this specific case. See below.

Could someone explain why findfun works while findvar doesn't? I've been looking at the source code in envir.c, and it isn't really clear why one way works while the other doesn't.

Is it possible, given a variable/function name, to determine if it should use findFun or findVar? This would be helpful for the polymorphic static typing of R values.

> yziquel_at_seldon:~/git/ocamlr-quantmod$ ocaml-batteries
> Objective Caml version 3.11.1
>
> _________________________________
> | | | |
> [| + | | Batteries Included - |
> |_______|_|_______________________|
> _________________________________
> | | | |
> | - Type '#help;;' | | + |]
> |_______________________|_|_______|
>
>
> # #require "R.interpreter";;
> # let show = R.Pretty.t_of_sexp;;
> val show : R.sexp -> R.PrettyTypes.t = <fun>

findFun works.

> # let str = R.findfun (R.install "str");;
> val str : ('_a -> 'b) R.t = <abstr>
> # let lm = R.findvar (R.install "lm");;
> val lm : 'a R.promise = <abstr>
> # R.eval [str; lm];;
> function (formula, data, subset, weights, na.action, method = "qr",
> model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE,
> contrasts = NULL, offset, ...)
> - : R.sexp = <abstr>

findVar doesn't.

> # let str = R.findvar (R.install "str");;
> val str : 'a R.promise = <abstr>
> # R.eval [str; lm];;
> Erreur dans function (object, ...) :
> function générique incorrecte dans 'UseMethod'
> Exception: Failure "OCaml-R error in r_eval_sxp C stub.".
> #

All the best,

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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 01 Dec 2009 - 12:01:53 GMT

This archive was generated by hypermail 2.2.0 : Tue 01 Dec 2009 - 15:10:53 GMT