assignment slots (was: two questions...)
Jecel Mattos de Assumpcao Jr.
jecel at lsi.usp.br
Mon Apr 11 02:31:00 UTC 1994
Randall.Smith at Eng.Sun.COM (Randy Smith) wrote:
> [ .... ] We have talked about redoing assignment,
> though it's not in our current plans. One proposal is to make the
> assignment primitive method (sometimes written as "<-") take an argument
> specifying which slot it assigns to. You might write this new
> assignment primitive method as "<-[slotName]"
> [ ..... ]
> A trap to notify reads would be
> x = ('Read x !' printLine. trueX ).
> x: arg = <-['trueX'].
> trueX = 7.
> [ .... ]
> There are two downsides to this proposal (that I have heard so far).
> 1] Today when you see an assignment slot in an object (| x <- 7 |), you
> know that there are two slots, and that x: is not trapped: it is
> guaranteed to contain "<-". This simplifies the browsing task facing
> the programmer.
Here is another idea for assignments: how about making the assignment
slot contain actual Self code that calls the special primitive. I
will use a binary message selector "<-" here, but "_Assign:" would
work as well. Let us suppose, initially, that this special primitive
can only be used with an implicit self as receiver and that assignment
slots are associated with their data slot by name.
( | x <- 7 | )
will mean the same thing as:
( | x = 7. x: arg = ( <- arg ) | )
but we can have more complex assignments:
( | x = 7.
x: arg = ( count: count + 1. <- arg ).
count <- 0
I think this would do away with most of the need to assign to an
arbitrary data slot. This would mean that the compiler would have
to do two lookups to find the data slot that the "<-" refers to.
The system could conserve space, on the other hand, by making
all simple assignment slots point to the same "( <- arg )" code
If it is important to decouple the assignment slot name from the
data slot name, we might borrow the syntax for directed resends:
( | x = ( Read x !' printLine. trueX ).
x: arg = ( trueX.<- arg ).
trueX = 7.
Although this idea muddles some of Self's semantics, it looks more
like an integral part of the language.
More information about the Self-interest