Daniel Nugent wrote:
> Adam, there's two things here:
> 
> 1) When you're using an object in Ruby, the *only* way to interact
> with it is to send messages to it.  This is uniform across the
> language and a damned good idea if you ask me.  Mixing methods with
> accessing fields is a bad idea in my book.

I'm not intending to talk about mixing methods with accessing fields.  I 
realize that in Ruby all fields are private in the ruby sense, and I'm 
fine with that.  I'm only talking about calling methods, or sending 
messages, however you want to describe it.

> 
> 2) Ruby provides the Java private method access level with protected,
> as mentioned earlier in the thread.

This information is actually incorrect.  The Java and Ruby definitions 
of "protected" are pretty much the same (minus some package scope stuff 
in Java which doesn't apply to Ruby).  From the Pickaxe:

A protected member can be invoked only by objects of the defining class 
*and its subclasses*.

Your description and the earlier post you refer to left out the "and its 
subclasses" part.  If there are parts of a class I write which I want to 
be considered as implementation details, subject to change, then I 
surely don't want subclasses that other people write to use those 
features.  I want to be able to update my class's implementation, re-run 
the class's unit tests (which test the class's public and protected 
interface), and as long as nobody has used instance_eval to use private 
members, no other code should break.   Given that the main use I see for 
private is to encapsulate code which I don't want anything outside this 
class to depend on, I don't see the point of saying objects can only 
invoke private methods on themself.  It's the unit of code that I'm 
trying to protect from other code, not the object from other objects.

> Yes, it requires you explicitly
> declare member variables as protected, but if you're dead set on
> giving objects access to all the instance variables, you can
> definitley do that.

I'm not dead set on anything, especially since it's easy to just use 
instance_eval if I want to.  I'm just suggesting that Ruby's definition 
of private is of debatable use, and seeing if anyone has a good 
explanation for why it is the way it is, other than defensive statements 
like "'Cause Ruby ain't Java."

Adam