Naive questions on cascade syntaxe

Dan Ingalls Dan at SqueakLand.org
Sun Dec 30 16:46:49 UTC 2001


ducasse <ducasse at iam.unibe.ch>  wrote...

>I'm trying to come to the simplest set of rules to put () around Smalltalk
>expressions. I'm on the cascade.
>
>is it correct to say that a cascade is
>   - either without () I mean outside of the cascade
>    this happens when there is no message send to the cascaded expressions
>    itself like in x := Set new add: 5 ; yourself
>   
>   - either there is one message not in the cascade and the cascade should
>be parenthesised.
>    like in
>        (x := Set new add: 5 ; yourself) class
>    or  (Set new add: 5 ; yourself) + 2
>    or  (Set new add: 5 ; yourself) includes: 5
>
>I read the ANSI standard but could not really found a clear description.
>
>Then inside the cascade you need () only if the receiver expression selector
>is a keyword and that you have keyword in the messages
>
>    examples:
>        Set new add: 5 ; add: 5 ; yourself (the formatter of VisualWorks put
>() around Set new but I guess that this is just to stress the receiver).
>        Set new reset; reset ; reset
>        with binary I do not see what example would not be silly
>        (Set with: 5) add: 6 ; yourself

I don't know what ANSI says, but...

A cascade is a series of messages sent to the same receiver.
The receiver that is used is the receiver of the (outermost)
	message that precedes the first semicolon.

Another way of thinking about it is...
	r m1; m2; m3; m4
is essentially equivalent to
	x := r.
	x m1.
	x m2.
	x m3
except that this is not an expression (it's a block body), and there's an extra temp needed here.

I suppose the most exactly equivalent form would be
	r in: [:x |
		x m1.
		x m2.
		x m3]
because this scopes its extra temp, and it is an expression.

I couch these all in terms of replacements because I assume (am I right? ;-) that you are experimenting with elimination of cascades.

	- Dan




More information about the Squeak-dev mailing list