[self-interest] Assignement return value
David Ungar
David.Ungar at Eng.Sun.COM
Sun Sep 10 23:44:55 UTC 2000
Just to try to clear things up,
the assignment primitive should return the receiver of the assignment.
So (| method = (|a| a: 3|) method does the following:
The message send of "method" runs the method with the object
(| method = ...|) as receiver.
The assignment returns the receiver and the method returns last
expression, namely the receiver.
So the code should return just the same (| method = ...|) object as
was sent the original method.
Why did we specify Self this way?
The idea is that anything that does not return a particular,
interesting value, just returns the receiver and we wanted to be
consistent.
That way, you would expect the same result value from "a: 3" as from
"foo: bar" or even
"display: something". The idea was to unify assignment with a message
that only took one argument and it would have been weird for random,
one-argument messages to return the argument as their result.
Was it the best choice?
Beats me, but I still like it.
BTW, all this interest is really gratifying.
Anyone coming to OOPSLA?
- Dave
At 4:17 AM +0000 9/10/00, Marko Mikulicic wrote:
>Hello,
>
>can anybody with a running self system evaluate this expression:
>
> ( | method = ( | a | a: 3 ) | ) method
>
>Under JSelf it returns nil. This means that the assignement primitive in
>
>expression "a: 3" returns the
>"self" and not the new value of "a". Is this correct ?
>
>and: ( | method = ( | a | a: (a: 3) . a ) | ) method
>
> should return also "self". (JSelf can't execute this one).
>
>thanks
>
>
>Marko
--
David Ungar
Sun Microsystems Laboratories
(650) 336-2618
More information about the Self-interest
mailing list