Terminal keywords [was: Squeak (ST80) syntax]

Dan Ingalls Dan.Ingalls at disney.com
Thu Feb 17 23:53:04 UTC 2000


Aran Lunzer <aran at meme.hokudai.ac.jp> wrote...
>So there would have to be something special about a terminator that
>marked it as such.  Hmmm...
>
>   aStream read: inputHandle :upToCR.

A generalization of this approach would be to preface ALL keywords after the first with a colon.  This leads to the following pattern

	collection at: key :put: value.
...with trailing keyword now completing a certain symmetry...
	collection at: key :put: value :returnSelf.

Oh, boy!  More colons.  But wait, there's more....

While this is pretty clunky, note that colons used in this manner, if detached, are basically delimiters like parentheses, suggesting a simple transformation to colon-free keyword syntax:

	collection at (key) put (value).
and similarly
	collection at (key) put (value) returnSelf.

Here the extension to optional trailing keywords merges with the rule for unary messages.  The rule for method names remains the same:  the selector is the agglutination of all keywords (*).

In fact this parallels one of the experiments at Squeak Central for dealing with "colon cancer".  I just thought it was neat how Aran's suggestion, generalized and transformed, takes you to a completely equivalent syntax that many would say is more "normal".


Also, on the topic of terminal keywords, I can't help reminding people that ST-76 allowed an assignment arrow (I'll use := here) as a terminal "keyword".  This led to a very nice symmetry of read/write access:

	a := stream next.  "unary"
	stream next:= a.

	a := array @ i.  "binary"
	array @ i := a.

	a := matrix row: r col: c.  "keyword"
	matrix row: r col: c := a.

Besides the symmetry, the one other attractive property was that the assignment brought with it an extra level of precedence, so that one could write

	array @ i := a max: b

without needing parentheses around (a max: b) as one does with ST-80's at:put:.

	- Dan

(*) one would still want to include a dot or colon where the arguments go for disambiguation and ability to tell arity by inspection, as in #at:put:, and #at:put:returnSelf.






More information about the Squeak-dev mailing list