[MacRuby-devel] Thoughts about aliasing

Laurent Sansonetti lsansonetti at apple.com
Thu Dec 10 14:43:11 PST 2009


Hi Jordan,

We are aware of this problem, but AFAIK we do not have a Trac bug for  
it yet. Feel free to file a ticket :)

Laurent

On Dec 10, 2009, at 1:10 PM, Jordan Breeding wrote:

> 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
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list