Hi --

On Wed, 18 Aug 2004, Brian Palmer wrote:

> So yeah, the whole "on_#{arg}= a" thing is a hack, but += doesn't
> behave as I would expect when used after a method.  I would think it
> would call the method first, and then call += on its return value.
> But it calls the method, calls + on its return value, then calls the
> method= version of the method.

The way you're describing can't really work, though; you'd end up with
the problem of altering immutable values (the same thing that has led
Matz not to have a ++ operator):

  obj.x = 1
  obj.x += 1  # would resolve to: 1 += 1, which is: 1 = 1 + 1

The syntactic sugar transformation (a += b to a = a + b) has to happen
before anything else happens that could turn the lhs into a
non-l-value.


David

-- 
David A. Black
dblack / wobblini.net