question on calling super methods in macruby
In RubyCocoa if I had: def initWithFrame(frame) super_initWithFrame(frame) # do other stuff self end In MacRuby would I just do this: def initWithFrame(frame) super.initWithFrame(frame) # do other stuff self end or even just def initWithFrame(frame) super # do other stuff self end
Hi Richard, MacRuby is about getting as ruby-ish as possible. Thus you should simply use the keyword super, your third example. Cheers, Eloy On Jun 12, 2008, at 1:58 PM, Richard Kilmer wrote:
In RubyCocoa if I had:
def initWithFrame(frame) super_initWithFrame(frame) # do other stuff self end
In MacRuby would I just do this:
def initWithFrame(frame) super.initWithFrame(frame) # do other stuff self end
or even just
def initWithFrame(frame) super # do other stuff self end
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Awesome, thanks Eloy. I love the ability to do stuff like this: path.curveToPoint NSPoint.new(rounding, 0), controlPoint1:NSZeroPoint, controlPoint2:NSZeroPoint It was so syntactically nasty under RubyCocoa! Best, Rich On Jun 12, 2008, at 8:08 AM, Eloy Duran wrote:
Hi Richard,
MacRuby is about getting as ruby-ish as possible. Thus you should simply use the keyword super, your third example.
Cheers, Eloy
On Jun 12, 2008, at 1:58 PM, Richard Kilmer wrote:
In RubyCocoa if I had:
def initWithFrame(frame) super_initWithFrame(frame) # do other stuff self end
In MacRuby would I just do this:
def initWithFrame(frame) super.initWithFrame(frame) # do other stuff self end
or even just
def initWithFrame(frame) super # do other stuff self end
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
I agree, although the amount of code I have written in RC still makes it a bit harder for me to get used to the new syntax. Although it is much better of course :) Eloy On Jun 12, 2008, at 2:17 PM, Richard Kilmer wrote:
Awesome, thanks Eloy.
I love the ability to do stuff like this:
path.curveToPoint NSPoint.new(rounding, 0), controlPoint1:NSZeroPoint, controlPoint2:NSZeroPoint
It was so syntactically nasty under RubyCocoa!
Best,
Rich
On Jun 12, 2008, at 8:08 AM, Eloy Duran wrote:
Hi Richard,
MacRuby is about getting as ruby-ish as possible. Thus you should simply use the keyword super, your third example.
Cheers, Eloy
On Jun 12, 2008, at 1:58 PM, Richard Kilmer wrote:
In RubyCocoa if I had:
def initWithFrame(frame) super_initWithFrame(frame) # do other stuff self end
In MacRuby would I just do this:
def initWithFrame(frame) super.initWithFrame(frame) # do other stuff self end
or even just
def initWithFrame(frame) super # do other stuff self end
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
As Eloy says, super will work as expected. We try to support super in RubyCocoa too but it was very hard to implement (and it was also causing regressions), thus the necessary super_foo method. On the other side, you cannot do the following in MacRuby: - (id)init { return [super initWithFrame:NSZeroRect]; } (E.g. calling a different super method.) But I don't think we should provide a way to do this in MacRuby, because Ruby itself doesn't allow you to do that. MacRuby is Ruby after all. Laurent On Jun 12, 2008, at 5:08 AM, Eloy Duran wrote:
Hi Richard,
MacRuby is about getting as ruby-ish as possible. Thus you should simply use the keyword super, your third example.
Cheers, Eloy
On Jun 12, 2008, at 1:58 PM, Richard Kilmer wrote:
In RubyCocoa if I had:
def initWithFrame(frame) super_initWithFrame(frame) # do other stuff self end
In MacRuby would I just do this:
def initWithFrame(frame) super.initWithFrame(frame) # do other stuff self end
or even just
def initWithFrame(frame) super # do other stuff self end
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Eloy Duran
-
Laurent Sansonetti
-
Richard Kilmer