[GOODIE] Arithmetic assignments (+= and friends)
Alan Kay
Alan.Kay at squeakland.org
Tue Jun 18 16:53:00 UTC 2002
This is an interesting sidepath.
In the original Smalltalk-72, a variable was an object, had a class,
and one could add methods to it. On the other hand the usual use of a
symbol in an expression connotes the associated value of the symbol
in some context through some lookup process. But LOGO had used ":" to
mean "value of" to help kids with this sometimes confusing area.
Also, unbeknownst to us, Prolog decided to mark actual variables for
which there would be some kind of dereferencing process. So we
experimented with marked variables for a while. But we finally wound
up with something like the LISP conventions for quoting.
So, "assignment" in the main version of Smalltalk-72 looked like"
'a <- 5
where this literally meant send the message "<- 5" to the object "a".
The object "a" used a method in its class to deal with the context
lookup to retrieve the association. The first group of children came
up with an iconic hand with a pointed finger to stand for "quote" --
for them to make clear that this meant the object "a" itself not what
it might stand for.
So
a <- 5
meant send the message "<- 5" to the object currently "in" the
variable "a". This looks dangerous (and is), but it is very useful to
monitor what is happening with "a", to cause events on a store, etc.
And
'a <+ 5
meant send the message "<+ 5" to "a", and the conventional meaning of
this was to increment the value associated with "a" by 5. Etc.
This is just to point out that full objectification of Smalltalk will
lead to reasonable readings of what Andreas has added.
Since a fair amount of my original motivation in trying to invent an
OOP language in the late sixties was to get rid of assignment as an
operation and turn it into just another message, it is ironic that
the later Smalltalks didn't pay as much attention to this as they
probably should have. Smalltalk-76 had a better syntax than -80 for
dealing with some of the overloading, but still didn't really
materialize variables or bindings as classes with real objects. The
at-put conventions of -80 are particularly annoying to me.
(Most of these choices were for reasons of efficiency, but I
think the later work of SELF and the MOP show that it is better to
have a really clean general semantics with a fully objectified
metamodel, and then use (automatic) compilation to get efficiency.
Cheers,
Alan
-------
At 11:08 AM -0400 6/17/02, Diego Gomez Deck wrote:
>Hi Andreas,
>
>>Diego,
>>
>>> To say the true, I don't like any option.
>>
>>Well, that's okay - I didn't say you have to like it (neither did I say
>>you have to file it in or even to use it ;-)
>
>I'm only trying to avoid the inclusion in the 'official' updates.
>
>>> If you want, try to remove the assigment (the only not a
>>> message thing) and not to expand it.
>>
>>No, I don't want to. If it's your interest to remove assignment *you* go
>>for it ;-)
>
>Not for now, We'll see in the future.
>
>>I have no interest in any kind of minimal syntax. And the
>>complexity of explaining that += means "increase this variable's value
>>by X" doesn't seem a big hurdle to me.
>
>This is not true in Smalltalk.
>
>I read:
> a += 2.
>
>as: Send the message #+= to the object named a and then name a to the answer.
>
>and I feel more natural to write:
>
> a := a + 1.
>
>because is more direct the translation.
>
> someName := SomeObject.
>
>is translated as: 'name someName to the object to the right side'
>
>>Cheers,
>> - Andreas
>
>Cheers,
>
>Diego
>
>PS: Will We see at SqueakNic the June/22?
--
More information about the Squeak-dev
mailing list
|