[MacRuby-devel] [MacRuby] #370: Inconsistency between macruby and ruby in a simple class
MacRuby
ruby-noreply at macosforge.org
Fri Oct 9 04:05:16 PDT 2009
#370: Inconsistency between macruby and ruby in a simple class
-----------------------------------+----------------------------------------
Reporter: kfowler@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: major | Milestone: MacRuby 0.5
Component: MacRuby | Keywords:
-----------------------------------+----------------------------------------
Comment(by conradwt@…):
Yes, there's seems to be an issue with the initialize method returning the
instance to the caller. However, you can rewrite the classes as follows
and the initialize method seems to work as expected:
{{{
W = Class.new do
define_method :initialize do |w|
@w = w
end
end
M = Class.new do
define_method :initialize do |m|
@m = m
end
end
printf("%s\n" , W.new(W.new(1)).inspect)
printf("%s\n" , M.new(M.new(1)).inspect)
printf("%s\n" , W.new(M.new(1)).inspect)
printf("%s\n" , M.new(W.new(1)).inspect)
}}}
Next, adding 'self' as the last executable statement within the
'initialize' method provides a temporary workaround. Finally, if I'm
reading the code correctly, the function 'rb_class_new_instance0' within
the 'object.c' file may be a starting point for resolving the issue.
--
Ticket URL: <http://www.macruby.org/trac/ticket/370#comment:3>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list