[graalvm-users] Interop from R to Ruby

Stepan stepan.sindelar at oracle.com
Wed Aug 22 00:53:18 PDT 2018


Hi Rodrigo,

the way you invoke foreign functions from FastR is just to invoke them 
like if they were R functions: "rb_method(args)" should work. We will 
soon update the documentation with the following:

How to send interop messages from FastR to TruffleObject x:
READ:           x$field
                 x at field
                 x[4], x["field"]
                 x[[4]], x[["field"]]
INVOKE:         x at method(args)
EXECUTE:        x(args)
                 x$method(args)
WRITE:          x$field <- value
                 x at field <- value
REMOVE:         x$field <- NULL (TBD)
                 x at field <- NULL not supported, because S4 objects do 
not support removal of slots
IS_NULL:        is.null(x)
GET_SIZE:       length(x)
HAS_SIZE:       length(x) != 0 (because e.g. length(new.env()) == 0)
KEYS:           names(x)
HAS_KEYS:       names(x) != NULL
NEW:            new(x)

Best,
Stepan

On 21/08/18 19:56, Rodrigo Botafogo wrote:
> Hello…
> 
> I’ve being accessing R from Ruby with success with calls to 
> Polyglot.eval. like:
> 
> func = Polyglot.eval(“R”, “c”).call(1, 2, 3)
> 
> I’m now trying to do a callback from R to Ruby. I’ve tried something like:
> 
> |class Callback def f(x, y) Math.cos(y) / (1 + x^2) end end remote = 
> Polyglot.eval("R", <<-R) function(rb_method) { rb_method.call(1, 2) } R 
> remote.call(Callback.new.method(:f)) |
> 
> But this doesn’t work. Is there an easy way of making this callback? And 
> what about sending an instance of a class instead of a function?
> 
> Thanks
> 
> -- 
> Rodrigo Botafogo
> 
> 
> 
> _______________________________________________
> GraalVM-Users mailing list
> GraalVM-Users at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/graalvm-users
> 



More information about the GraalVM-Users mailing list