Naive questions on cascade syntaxe

ducasse ducasse at iam.unibe.ch
Sun Dec 30 18:32:40 UTC 2001


Hi Dan

I'm just writing a pretty printer. I took the Squeak one and made a
visitor-based one. I realized that if a node would have a back pointer to
its parent node this would make life easier because we could hold directly
the context of the node even when recursively treating it.

I think that with this pretty printer we will be able to experiment more
deeply with alternate syntax in a plug and play fashion and not patches
everywhere. But doing a pretty printer is boring ;)
 
> 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.

By outermost do you mean the same as me:

in Set new add: 1; ....

the instance aSet is the receiver
In my lecture I say that the messages in the cascade are sent to the
receiver of the first one message.  the first  message being one the left of
the first ; 


> 
> 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 was trying to see if the following expression was parsed by Squeak

Set new add: 5 ; add: 5 ; yourself includes: 5
and in fact the parentheses are needed because a cascade is an expression
(in fact the opposite). But I was looking for the real reason and the ; is
really defining a different expression.

 
> 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 like this one. 
 
> I couch these all in terms of replacements because I assume (am I right? ;-)
> that you are experimenting with elimination of cascades.

I'm not always in the mood of eliminating everything ;) My embryonical
pretty printer even pretty print {} ;)

> - Dan






More information about the Squeak-dev mailing list