[MacRuby-devel] Thoughts about aliasing

Jordan Breeding jordan.breeding at me.com
Thu Dec 10 13:10:53 PST 2009


I was thinking that especially when testing the performance of a pure ruby based class (Set) against a Cocoa class (NSSet/NSMutableSet), it would be useful to alias methods in the Cocoa side of things. My thought was then you could have a single API to use in the rest of your code and you can just switch which class you are using.

In my case I wanted to alias include? to containsObject and add to addObject.

I suppose that this could also be done by aliasing on the ruby side of things (alias containsObject to include?), right now I just create methods that forward for me.

What I was wondering is if it would be useful to be able to have something like this work in the future:

{{{
class NSSet
    alias include? containsObject
end
}}}

Right now you will get "only pure Ruby methods can be aliased (`containsObject:' is not) (ArgumentError)". But I was thinking maybe when it sees that the original method is pure ruby it could act as it currently does, but then when it sees an Objective-C method as the original it could do something like on the Objective-C side use method_getImplementation() and method_setImplementation() to create the alias for you anyway.

Would this be desirable? Should I create a ticket for it?

Jordan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3820 bytes
Desc: not available
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20091210/e3fff21e/attachment.bin>


More information about the MacRuby-devel mailing list