On 07/05/2010, at 2:17 PM, Thibault Martin-Lagardette wrote:

> Glad it works :-)
> 
> The reason why your example doesn't work is because in MacRuby, String 
> descends from NSString, which is a Foundation object. Foundation objects use 
> "init" and not "initalize", and for syntaxic sugar reasons, #new is aliased 
> to [[obj alloc] init] on Foundation objects :-).

oh, I understand the implementation detail, I just think it's wrong for a Ruby 
implementation to behave that way - this isn't just a matter of extending Ruby 
syntax to support access to Obj-C but rather a change that can break existing 
Ruby code...

what I would expect in this case is for the class I've written in ruby to have 
initialize called like all other classes written in ruby, and leave it to me to 
correctly call the designated initializer of my superclass, which I know is 
-init because I'm subclassing Obj-C code...


> On non-Foundation objects, #new behaves as you expect (the ruby way)

yeah, and with things like my OpenDirectory wrapper I can live with it... but 
when the behaviour of subclassing standard Ruby types differs between the 
reference implementation and MacRuby I'd be calling that a bug in MacRuby...


> I agree this difference can be confusing, and I think it could find its place 
> in a certain book *stares at Matt*

it doesn't need documenting, it needs fixing... :)

I guess it all depends whether you're looking at MacRuby as a new language for 
writing Cocoa applications, or as a runtime for Ruby applications on OSX...

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to