Eliminating assignments and variable syntax (accessors)

Travis Griggs tgriggs at keyww.com
Mon Aug 2 21:22:38 UTC 1999


Stephen Pope wrote:

> This is getting a bit involved, but I have another idea. First, two
> principles:
>
> 1) We should keep the receiver in message patterns. (I'm against
> abbreviated message-sends.)
>
> 2) We want to get rid of assignment. (It's always a hack, except if you
> make it a function as in LISP, or do away with it, as in functional
> languages.)
>
> Solution: If we had the notion of "implicit accessors," we could write,
>
>     | var |
>     self var: 42.
>     Transcript show: self var printString; cr.
>
> The code that implements doesNotUnderstand (or, even better, handles the
> exception MessageNotUnderstood) could then look in the local scope to
> see if there's a variable named "var" and handle the assignment and
> reference as "implicit accessing" -- this way it appears that we have
> accessors even for local temp. vars.
>
> (This is very similar to several other schemes that use
> doesNotUnderstand for "generic behavior" or property list objects.)
>
> If we did it this way, we could do away with all accessors (except for
> the speed hit we'd take passing though doesNotUnderstand on IV
> accesses).

But if we did it this way, that would also allow one to still write explicit
accessors/setters which would be good both for cases where efficiency was
important and cases where you want to invoke side affects. I like this
proposal. You could extend it on the MetaClass side to make the implicit
setters pass thru to the new instances. And you could do arbitrary ordered
argument lists as well (I did this about 1 year or so ago in Squeak).

--
Travis Griggs (a.k.a. Lord of the Fries)
Member, Fraven Skreiggs Software Collective
Key Technology
P-P-P-Penguin  Power!





More information about the Squeak-dev mailing list