pipe

Ramon Leon ramon.leon at allresnet.com
Mon Aug 27 22:23:23 UTC 2007


> Just for fun - the tiny attached change-set allows #asPipe to 
> get piping behavior for cascades:
> 
> Squeak asPipe
> 	ps: 'aux';
> 	grep: 'fabio';
> 	sort
> 
> It makes these two expressions equivalent
> 
> 	((((4 + 2) * 3) + 3) * 2)
> 
> 	4 asPipe + 2; * 3; + 3; * 2
> 
> Now I wouldn't use this in production but for interactive 
> exploration it might actually be useful. Similar to 
> implementing Symbol>>#value:  
> to allow "(1 to: 10) collect: #squared".
> 
> Btw, did you know each class can declare its own parser and 
> compiler class? Experimenting with the syntax does not 
> necessarily have to break other's stuff.
> 
> - Bert -

Hey Bert, this is actually a pretty cool hack, being standard syntax, none
of the tools break (refactoring browser, pretty printer).  This could be
useful in production with a bit of self optimization.

Just for fun, attached is your class with #doesNotUnderstand: passing the
message to a method that compiles keyword messages into delegation methods
on the fly to avoid the overhead of dnu and #perform for future calls.

Ramon Leon
http://onsmalltalk.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Pipe.st
Type: application/octet-stream
Size: 1304 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070827/ba9b2c6f/Pipe.obj


More information about the Squeak-dev mailing list