Tomasz Wegrzanowski wrote:

> [snip]

> So I think it would be good idea to have method visibility controls
> removed because:
> * They do not fit Smalltalk-style OO, so removing them would make
> everything simpler
> * We get very limited benefit from them due to lack of C++/Java-style
> features like per-class namespaces for private methods (or even
> instance variables), and ability to call private methods of other
> objects of the same type
> * They make metaprogramming, unit testing etc. more difficult
> * They provide very limited control over visibility
> * Very simple Ruby metaprogramming gives us much more powerful private
> variables anyway.
> * I think it's unlikely for current visibility control system to lead
> to any cool things. As far as I can tell it was never used for
> implementing any magic. There is no obvious way to add any features
> (even to get them to the level of that metaprogramming snippet)
> without greatly complicating the language.
> * Ruby 2 is exactly the right time for doing such changes

At times I have had such thoughts too. After all Ruby is largely a
Document and Test oritented language b/c of it's high degree of
dynamicisim. There is at least one feature of the private/protected vs.
public system that is valuable though: you can catch public calls via
method_missing even when there are private/protected methods defined.
Eg.

  class X
    def method_missing( name ); name; end
    private
    def bird; "hoot!"; end
  end

  x = X.new
  x.bird  #=> "bird"
  x.send(:bird) #=> "hoot!"

I only recently came to understand this myself and it made a big
difference in how I handled certain usecases of method_missing. Unless
you see a better way to hadle this, then I think the private/protected
vs. public distiguish it useful.

As a side note, I sure would like to see class/module local methods
(not part of inheritance chain) if possible.

T.