#787: MacRuby Initializers only claim a single arity
----------------------------------------+-----------------------------------
Reporter: ernest.prabha...@… | Owner: lsansone...@…
Type: defect | Status: new
Priority: major | Milestone: MacRuby 0.7
Component: MacRuby | Keywords:
----------------------------------------+-----------------------------------
When I write an initalizer, I only register it for a single arity:
rb_objc_define_method(cQueue, "initialize", rb_queue_init, 1);
Queue.new("foo")
Unfortunately, Objective-C will apparently fall back to the default (no-
arg) initializer of the superclass, leading to an uninitalized object
being allocated if I mistakenly call:
Queue.new # no args
To work around this, I've manually added an exception-throwing
initializer:
static VALUE
rb_raise_init(VALUE self, SEL sel)
{
rb_raise(rb_eArgError, "initializer called without any
arguments");
return self;
}
rb_objc_define_method(cQueue, "initialize", rb_raise_init, 0);
Would be nice if MacRuby did this automatically, to preserve Ruby-esque
semantics.
--
Ticket URL: <http://www.macruby.org/trac/ticket/787>
MacRuby <http://macruby.org/>
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel