pipe

leves at elte.hu leves at elte.hu
Sat Aug 25 17:35:40 UTC 2007


> Fabio's proposal:
>
> make the ";" cascade operator send the message not the the previous   
> receiver but to the object returned by the previous message send.

This would break most code with cascades, like:

o add: 1; add: 2; yourself.

Pipes might be useful in some cases, so one can add the following  
message to Object:

pipe: aBlock

     | catcher pipedObject |
     catcher := MessageCatcher new
         privAccumulator: OrderedCollection new.
     aBlock value: catcher.
     pipedObject := self.
     catcher privAccumulator do: [ :each |
         pipedObject := each sendTo: pipedObject ].
     ^pipedObject

Then simply use ; as a pipe like:

1 pipe: [ :mock |
     mock + 3;
     - 2;
     asFloat;
     * 2;
     asString;
     , ' foo';
     , ' or bar';
     first: 10 ]





More information about the Squeak-dev mailing list