[graalvm-users] How to dynamically check type
Rodrigo Botafogo
rodrigo.a.botafogo at gmail.com
Tue Jun 12 13:39:22 PDT 2018
Hello,
Is there a way to dynamically check the type of a Truffle::Interop object?
For instance, in this code:
# evaluate an integer in R and return the result of this evaluation
# this is just an integer
var = R.eval("4")
puts ("Double evaluated in R: #{var}")
p var.is_a? Integer
>> false
# Create a list in R, that is anonymous in R but available to Ruby.
# We are now using method_missing to resolve the 'c' method.
val = R.c(1, 2, 3, 4)
p val
>> #<Truffle::Interop::Foreign at 299cab08>
p val.is_a? Integer
will raise an exception on the val.is_a? Integer
Internal error occured: org.graalvm.polyglot.PolyglotException:
org.truffleruby.language.control.RaiseException: Message not supported:
INVOKE (UnsupportedMessageException)
I understand the message and why, but this kind of breaks the ability to
check types dynamically and every code that does that.
As a programmer, I would like to see Interop inherit from the Object Class
so that it works as any other Ruby object. Better yet, if I could identify
at runtime the language the Interop pointer is referencing: Ruby, Python,
etc. Is this possible?
Probably I'm missing something... comments?
Thanks a lot
--
Rodrigo Botafogo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/graalvm-users/attachments/20180612/de2b1101/attachment.html
More information about the GraalVM-Users
mailing list