On Dec 17, 6:08 pm, MonkeeSage <MonkeeS... / gmail.com> wrote:
> On Dec 17, 6:44 pm, Paul <pdavi... / gmail.com> wrote:
> > A private method cannot be called with an explicit receiver -- even
> > self -- except when calling a private setter method, because otherwise
> > an assignment to a local variable will be assumed.
>
> > For example:
> > -----------------------
> > class Q
>
> >   def a1
> >     @p = nil
> >     self.p=(3)
> >     @p
> >   end
>
> >   def a2
> >     @p = nil
> >     p=(3)
> >     @p
> >   end
>
> >   private
>
> >   def p=(obj)
> >     @p = obj
> >   end
> > end
> > -----------------------
>
> > CONSOLE
>
> > >> Q.new.a1
> > => 3
> > >> Q.new.a2
>
> > => nil
> > -----------------------
>
> > Since there is already this exception to the rule, why not allow
> > explicitly using self for ALL private methods?  What harm can be done?
>
> I'm pretty sure that's the difference between protected and private
> visibility; protected lets you use an explicit receiver (and maybe
> other things like children classes can also access the method?). But
> if you need to use private methods, you can always call them with an
> explicit receiver by using #send.

I think you may be missing Paul's point. As shown in his sample code
above (which I have not tried but assume to be correct), there is a
particular syntax that allows self to be used with private methods.
Paul's question is "why not always allow it?"

The distinction between private and protected is only superficially
about whether an explicit receiver may be used. Primarily it is the
difference between...well, read for yourself:
http://phrogz.net/ProgrammingRuby/language.html#accesscontrol

I don't have an answer to Paul's question, or for/against his
proposal, but thought I'd clarify what I think may have been some
miscommunication.