[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax

From: Mike Anderson
Subject: Re: [Help-smalltalk] [RFC] Smalltalk scripting syntax
Date: Sat, 10 Mar 2007 18:43:37 +0000
User-agent: Thunderbird (X11/20061025)

Paolo Bonzini wrote:
>> Although I don't object to the syntax quite as much as you do, I do
>> think that some of the examples seem to violate the normal selector
>> precedence, and that is a Bad Thing. In particular this:
>> ChessPiece class >> test: side [ ... ]
> Note that this is no valid syntax in Smalltalk.  I see this "as if"
> the "test:" keyword where an object is expected introduces a
> "message pattern" which as the same precedence as an object (i.e.
> very high).
>> and this:
>> Class name: RandomInteger class [ ... ]
> Likewise, here the '[' where a keyword is expected introduce
> a "scoped definition" which has instead a very low precedence.

In the bit before that,

Class name: RandomInteger class

If I interpret the syntax correctly, #class is expected to be sent last,
 which is completely contrary to the normal rules of precedence. In this
situation, I think it would be far better to abandon the pretense that
these are message sends.

Actually, this is within the definition of RandomInteger, so surely
these tokens are superfluous: 'name:', 'RandomInteger', and one of
'Class' / 'class'. Could you not save some typing and have:

class [ "class methods" ]


class test: side [ ... ]


I've found something else that bothers me:

| instance variables |


ClassVar := Random new.

I feel that these should be more similar. :)

> It's like in standard math syntax, where "-/+" has high precedence if
> it is unary, and low precedence if it is binary.
>>> Then there are also a few minor other things that most people would not
>>> find to be a problem at all:
>>>   * "Object subclass: #SomeClass" is shorter and more to the point than
>>> "Class name: SomeClass extends: Object".
>> I agree. My opinion is that the first advertises the fact that
>> Everything Is An Object. Still, I can live with it.
> I would prefer "Object subclass: SomeClass" (okay, I know why you would
> like the hash).  If it is preferred, Daniele will implement it instead
> of "Class name: SomeClass extends: Object".
> The nice thing of "Class name: SomeClass extends: Object" is that it
> pairs nicely with the syntax to define class extensions, which is
>     Class name: SomeClass [
>         ...
>     ]
> Please comment on this.

Couldn't you simply write:

SomeClass [

or have I misunderstood?

>>>       <category> is followed by a
>>>       "comment", some
>>>       | temporary variables |, and an
>>>       ^answer.
>> I would hope that the syntax is still free-form, and all four of those
>> are optional, are they not?
> Of course.
> Paolo

Thank you for unblocking my other post :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]