self syntax (was: Killer Squeak App?)

Henrik Gedenryd Henrik.Gedenryd at lucs.lu.se
Thu Aug 23 10:48:10 UTC 2001


Thanks Jecel, 

these are all very informative comments. I don't want to start a flame war
and I know you like Self (ok, an understatement perhaps), but neither of the
three issues is an uncontestably perfect solution.

Jecel Assumpcao Jr wrote:

> 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.

It seems this would mean that you cannot simply read the code to see that it
is syntactically correct either (since its correctness is not a static
property). Unless you take clues from line breaks and such. But in all
fairness some ST syntax mistakes slip through the compiler in much the same
way.

>> 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".

But this is unfortunately still inconsistent, the implicit receiver is
sometimes self, sometimes "thisContext".

Since the context is seen as an extension of the object (the context has
the object in a parent* slot), I thought the simple solution would be to
simply consider (the implicit) self to be this "extended" version of the
receiver object.

>> 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

Whoa. Less parentheses yes. More readable? Hmm. Also, making the parsing be
sensitive to the capitalization of selector substrings is an "unorthodox"
approach to say the least. And parens help the eyes to segment things.


Another problem with the automatic accessors instead of assignment is that
you can't protect state from outside access and modification (unless you add
other mechanisms for hiding methods from the outside). There was some
feature of that kind in early versions IIRC?

In all, weighing the pros and cons of the syntax changes doesn't as
obviously come out in Self's favor as one first thinks. But of course it is
in the skill of an author to present any feature to its best advantage,
letting the downsides slip in the editing process ;)

Henrik






More information about the Squeak-dev mailing list