Mark Sparshatt wrote:Those are good points. There's no need for Python and other languages to know how Ruby handles it's method dispatch since it would be encapsulated in the RubyObect pmc's vtable functions.
The problem is what happens when some Python code tries to call a class method on a Ruby object? if Python doesn't know about the hidden reference within Foo it won't be able to find Foo' in order to call the method.
If I understand correctly, the Ruby object, as represented by a RubyObject PMC, knows about Foo'. That's enough, because the RubyObject handles the method dispatch anyway.
Let's say some Python code has a Ruby object, 'foo'. This Ruby object has a method named 'bar' in it. The code to call it would be something like this:
set P2, foo callmethod "bar"
That's it.
Really.
Well, not really, because there's all sorts of crud you have to set up under the Parrot calling convention. But the point is that the Python code doesn't go poking around in foo's guts to find the method--it just says, "Okay, foo, go run this method". foo is a RubyObject, so it dispatches according to Ruby's rules, even though it was called by Python.
If foo wasn't a Ruby object, but instead belonged to a language where dispatches are based on the phase of the moon, you'd better check your almanac, because your call from Python will reflect that too.
For a class method, I assume it'd look something like this:
getclass P2, foo callmethod "bar"
Once again, no poking around in foo's guts. Just "gimmie your class" followed by "run your bar".
I like the idea of a language where method dispatch is determined by the phase of the moon. I would suggest calling it Luna but I that that names been used already.
Thanks for the help
-- Mark Sparshatt