On Jan 23, 2007, at 4:45 PM, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: new method dispatch rule (matz' proposal)"
>     on Wed, 24 Jan 2007 09:15:56 +0900, Daniel DeLorme <dan- 
> ml / dan42.com> writes:
>
> |Ok, if private methods are not in a separate namespace, what  
> happens here?
> |  class A
> |    def foo; bar; end
> |    def bar; "A"; end
> |  end
> |  class B
> |    private :bar
> |  end
> |  B.new.foo #=> ?
> |
> |1. lookup in private methods starting at A => not found (in A, bar  
> is public)
> |2. lookup in public methods starting at B => not found (in B,  
> public bar has
> |been overwritten by private bar)
> |3. NoMethodError?
>
> Can I suppose B inherits A?
>
> If so:
>
>   * foo calls bar in functional style.
>   * private method search begins from A.
>   * when no private method found, start public method search from the
>     receiver's class.
>   * bar in class B will be skipped, since it's private.
>   * bar in class A is chosen.
>

I wanted to chime in with my feelings on this. I personally dislike  
it. Heres why:

1) Because of the current semantics, most ruby programmers treat  
self.foo the same as foo(). I'm very wary of making functional style  
behave much differently than normal method call style. It adds  
another layer and complexity and strangeness that I believe we do not  
need nor want. In fact, I think that it's a bug that private methods  
can only be called using functional style. The method dispatch  
mechanism can easily detect that the receiver of the method is the  
same all the current self end look for private methods.

2) As an implementor, I loath to think about having to have multiple  
dispatch paths that must be searched. We're already fighting with the  
outside world about the perceived slowness of ruby. Adding a new  
dispatch path that must be considered for EVERY functional style  
method call will only make things that much slower. Sure there are  
ways that we implementors can cache things to improve the situation,  
but I'd rather not have to if we can avoid it.


I worry that this new, perceived strangeness to users will mean that  
private will be used even less often then it's used now. And from  
what I've seen, it's very rarely used now.

Which brings up a good question.. whats protected for now?

> 							matz.
>