Hi Patrick,

> class Foo
>   def without_self
>     x=5
>   end
>
>   def with_self
>     self.x=5
>   end
>   
>   private
>   
>   def x=(value)
>     puts "x=#{value}"
>   end
>
> [...]
>
> Why is there no method call in Foo#without_self?

An expression that looks like ¡Æidentifier = value¡Ç always
sets a variable, and never calls a method.  This is simply
the way the language is defined.

When you want to call a setter method on the current object,
you *have* to say ¡Æself.foo = bar¡Ç, precisely because if you
leave out the ¡Æself.¡Ç, you will just create a local variable.

(You may encounter code that has each setter method aliased
to a names like ¡Æset_foo¡Ç or ¡Æset_bar¡Ç.  This of course
removes the need for the ¡Æself.¡Ç prefix, because ¡Æset_foo¡Ç
and ¡Æset_bar¡Ç can be called directly.)

> And why does self.x= [not] report an error?

As you have already pointed out yourself, private methods
may not normally be called with an explicit receiver.
However, there is an exception to this rule which says that
private setter methods *may* be called with an explicit
receiver, provided that explicit receiver is exactly ¡Æself¡Ç.
(No other receiver, not even ¡Æ(self)¡Ç, is excused.)

Of course, this exception exists precisely because it would
otherwise be very difficult to call a private setter method.

-- 
Daniel Brockman <daniel / brockman.se>

    So really, we all have to ask ourselves:
    Am I waiting for RMS to do this?   --TTN.