Eliminating assignments and variable syntax (accessors)
Stefan Matthias Aust
sma at netsurf.de
Mon Aug 2 21:55:06 UTC 1999
>1) We should keep the receiver in message patterns.
>2) We want to get rid of assignment.
We? :-)
>Solution: If we had the notion of "implicit accessors," we could write,
>
> | var |
> self var: 42.
> Transcript show: self var printString; cr.
But then do the full step and get rid of "| var |" That piece of syntax
isn't needed at all. Make local variable creation (wait, you don't have
variables so how to call them?) implicit. Python, btw, does the same and
for a Smalltalker who's already used to argumenting for the advantages of
dynamic typing against static typing it shouldn't be too difficult to also
find some arguments for these dynamic storage location ;-)
"self var: 42" simply creates a new local storage and assigns 42 if there's
no storage. Actually, it maintains a simply dictionary of key/value pairs.
We can even make this explicit
self localsAt: #var put: 42
Transcript show: (self localsAt: #var) printString; cr
Object>>localsAt: key put: value
(WeakMethodContextDict
at: thisContext sender receiver
ifAbsentPut: [Dictionary new])
at: key put: value
Object>>localsAt: key
^(WeakMethodContextDict at: thisContext sender receiver)
at: key
Of course, instead of self-sends, using symbols would also work :-)
But what's the benefit of this approach? I don't see it.
bye
--
Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf.
More information about the Squeak-dev
mailing list
|