I'd like to propose that we add a new low-level API to R_tryEval to
rpy2.rinterface. This would be lower-level than the existing
.__call__, .rcall methods, and have the following parts:
* rpy2.rinterface.tryEval (or whatever): a function that takes an
expression rinterface.Sexp, and an environment rinterface.Sexp, calls
R_tryEval, and returns a tuple (result, visibility)
* a way to create LANGSXP's from Python
* a way to create SYMSXP's from Python
* a way to create an environment directly (not via r.environment())

The advantages would be:
* It would let us replace the 300 lines (!) of tricky and redundant C
code implementing SexpClosure_rcall and Sexp_call (which at a quick
look also appear to have reference counting bugs) with a few lines of
Python.
* Having uniform access to visibility information would let us fix one
of the most annoying rnumpy bugs. (withVisible is ok for general code,
but it doesn't help for calls like r.plot(...).)
* More flexibility in how we pass expressions to R for evaluation. In
rnumpy, I would do calls like:
  env = new_env(base=globalEnv)
  env["<Python-wrapped function>"] = fn
  env["<Python-wrapped argument 1>"] = arg1
  ...
  (result, visibility) = tryEval([symbol("<Python-wrapped function>"),
symbol("<Python wrapped argument 1>"]), ..], env)
Then those names would be what showed up in tracebacks and plot
titles. This may seem trivial, but it's by *far* the most annoying
problem I run into when using rnumpy myself, and there doesn't seem to
be any other solution.

Does that sound sensible? I can write the code, but I wanted to throw
the idea out there to make sure it'd be welcome and I hadn't forgotten
anything, first.

-- Nathaniel

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to