[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: assignment, reference, += and parameter passing



David Simmons wrote:
> 
> The semantics of "+=" don't have this possible ambiguity in Smalltalk
> because "+=" is not a special operator. I.e., everything is a message
> and any message can be defined/redefined at any time by an implementor

Right. That's how it behaves in Python also. The problem is that the
built-in objects do not have consistent definitions for their behaviour
on receiving the "+= message". Some people want += to be a mutating
operator. But when it can't mutate the object (e.g. an integer), people
still want to be able to use it, so those classes define it such that it
creates a new object.

 Paul Prescod