Closed tshort closed 10 years ago
Yes, this is looking nice. I followed part this on the mailing-list (just too busy with other things to be more active at the moment).
I just had a quick glance and PyCall is using macros to define wrappers (functions) on the fly (the Python-R rpy2
interface is doing something similar, except that it is possible to define "callable" classes in Python so no need for macros).
R has a number of little surprises up its sleeve: "." (dot) is a valid character in a symbol name, as well as in a parameter's name but hopefully I'll be able to port most of the workarounds I implemented in rpy2
.
Hi Igautier!! Do you have some hints for implement this? I was thinking on ask to R for the functions and signatures in the first import, and generate a .jl
file with the wrap library.
The way I'd like to do it is pretty much the way I am doing it with rpy2
:
.
->_
majoritarily).Generating a .jl
file can reduce the computer's work at import time, but will require a number of checks at import time (like checking the version of the R package). From experience with rpy2
, this is not worth the trouble.
PyCall doesn't really need macros either, the macros are just to clean up the syntax slightly. Instead of @pyimport foo as bar
, you can equivalently do const bar = pywrap(pyimport("foo"))
.
I see. A nice side of macros.
What it could look like in Rif is:
stats = rimport("stats")
# the original R name is var.test - a similar conversion to what is done in rpy2's `importr()` takes place
stats.var_test(x, y)
How do I get Julia REPL console to autocomplete after a "." (dot) ? I am guessing that I should define a method, but it is not clear to me which one.
A pointer at the exact place in PyCall
implementating what let's it work with it would be fine.
In PyCall, the pywrap
function actually defines an anonymous module. So, the lookup of the fields after the .
is static, not dynamic.
I see. Pretty much like what is in rpy2
then.
I am almost done, I think, proven that someone can shed light on what is happening with the following bit inpywrap
:
eval(m, Expr(:toplevel, consts..., :(pymember(s) = getindex($(o), s)),
Expr(:export, exports...)))
This is in with the latest commits, although it is in a rough form (and Rif
needs a bit of work in several places).
The following is already working:
using Rif
rstats = Rif.rwrap("stats")
This is a feature request to make Rif work more like @stevengj's PyCall. With PyCall, one can do things like:
It would be great if Rif could make an
R
module and fill it with R function calls, so thatRif.call
isn't needed.Steven's handling of keyword arguments is also nice.