[MacRuby-devel] super_foo style RubyCocoa messages.
eloy.de.enige at gmail.com
Mon May 5 11:06:52 PDT 2008
>> I've started work on a RubyCocoa layer for MacRuby (still very
>> Like already discussed with Laurent, an API to be able to call the
>> superclass implementation of a method
>> will be necessary for super_foo style methods to work. Imagine this
>> class Foo < OSX::NSObject
>> def init
>> self if super_init
>> Something like this will be needed:
>> class OSX::NSObject
>> def method_missing(mname, *args, &block)
>> if superclass_method?(mname)
>> # convert mname to selector
>> super_send(selector, *args) # <- #super_send (or something like
>> it) should be able to send a message to the superclasses
>> original_method_missing(mname, *args, &block)
>> I hope this is clear enough?
> It is, but I have to say that I always found the super_foo syntax
> confusing in RubyCocoa. That's probably because I came to Ruby from
> ObjC, not ObjC from Ruby... I kept wishing that:
> super.foo() would work. Is that possible?
That syntax wouldn't work because calling "super" will call the method
you're in from the superclass.
AND it may/will return an object. In your example you are calling #foo
on the result object of the super call.
But that would be the functionality I suggest yes.
About the weird syntax in RubyCocoa, I agree.
But this wouldn't be a compatibility layer without supporting it's
intricacies now would it :)
PS: Is it me or is the return-path for the emails coming from the ML
incorrect? I guess it should point to macruby-
devel at lists.macosforge.org instead of Pierce...
More information about the MacRuby-devel