self syntax (was: Killer Squeak App?)

Jecel Assumpcao Jr jecel at merlintec.com
Wed Aug 22 23:10:04 UTC 2001


On Wednesday 22 August 2001 17:14, Henrik Gedenryd wrote:
> Stefan Matthias Aust wrote:
> > In the last squeak, I changed my mind an nowadays, Self has not
> > enough syntax for my taste. You really have to get used to all that
> > (| .. |) object declarations ( ) method declarations, implicit self
> > sends and the fact that even local variables doesn't exist.
>
> I'd like to hear your opinion: do you think it is an advantage to
> allow receiver self to be implicit? I have started to think that this
> breaks the simple principle of always having the "receiver message"
> pattern and thereby causes more irregularity than advantages. But I'd
> like to hear others' opinion on this, I don't have a strong opinion
> yet. Jecel and John Maloney might have something wise to say about
> this as well?

Since my Self/R has considerably *less* syntax than regular Self, I am 
not the right person to address Stefan's concerns.

But having used the "implicit self" trick in NeoLogo as well as Self 
and variations, I can say it is much more readable than what you might 
think from a first impression. It does make a missing statement 
separator (".") harder to spot since it becomes a run time error 
instead of being  flagged by the compiler as in Smalltalk.

> > I really the clean concept,
> > but using "name := 'sma'" instead of "name: 'sma'" or even
> > "objects[1] := objects[2]" instead of "objects at: 1 Put: objects
> > at: 2" would be more readable IMHO.
>
> It is wacky that you also address temps with the "temp: value"
> syntax. In effect 'self' is the inner context (cf. thisContext), not
> the object owning the method!

Exactly. If you write "self temp: value" it will work for "instance 
variables" but fail for "temporaries".

> A second effect of not having := is that there must be a lot more
> parentheses in the code. Ie.
>
> x := y blah: z  becomes   x: (y blah: z)
>
> This is a second thing I've come to think of as a possible
> disadvantage.

Self has two things that combine to make it need less parentheses than 
Smalltalk: all but the first keyword of a selector are capitalized and 
keywords parse from right to left. So the above expression would be

        x: y blah: z

and Smalltalk's

       x := y between: 0 and: (z min: 255)

would become

       x: y between: 0 And: z min: 255

-- Jecel




More information about the Squeak-dev mailing list