From: Rick DeNatale Date: 2007-12-19T09:19:57+09:00 Subject: Re: self and private setter On 12/17/07, Phrogz wrote: > I suppose it _might_ be a _small_ extra burden on the runtime to allow > this: > > class Foo > def call_bar( someone_else ) > someone_else.bar > end > private > def bar; end > end > > ...as the runtime would have to check if 'someone_else' was the same > as 'self' inside call_bar. Since it already has to check if the 'self' > inside call_bar is of the same class as the class as 'someone_else', > this doesn't seem particularly burdensome, however. No, it only has to do this for protected methods not private methods. For private methods the only check that's needed is whether or not there was a specified receiver, no need to dig down the call stack. In the case of self.x = y I'm almost certain that the parser turns this into the semantic equivalent of setx(y) where setx is a fictional alias to the :x= message selector. In other words it's just syntactic sugar for a functional form method call. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/