pipe

Marcel Weiher marcel at metaobject.com
Wed Aug 29 20:02:48 UTC 2007


On Aug 26, 2007, at 1:42 PM, Bert Freudenberg wrote:

> 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

Very cool!

Integrating (OO) dataflow, with pipes as a start, has been one of my  
short-term goals with Objective-Smalltalk/Arches.  So far, getting  
something up and running has been surprisingly easy, whereas getting  
something really consistent is proving a bit more elusive, mostly  
because it isn't really clear to me what consistent semantics should  
actually be.

Two examples:

Run an external command with an argument:

 > ls with:'/'
AppleInternal
Applications
Developer
Library
Network
System
Users
Volumes
bin
cores
dev
etc
home
mach_kernel
mach_kernel.ctfsys
net
private
sbin
tmp
usr
var
 >

External command piped into internal filter:

 > (ls with:'/')  | upcase
APPLEINTERNAL
APPLICATIONS
DEVELOPER
LIBRARY
NETWORK
SYSTEM
USERS
VOLUMES
BIN
CORES
DEV
ETC
HOME
MACH_KERNEL
MACH_KERNEL.CTFSYS
NET
PRIVATE
SBIN
TMP
USR
VAR
 >

The filter just processes #writeObject:  messages, with the runtime  
knowing that 'ls' returns text lines and therefore sending it

External command piped into external command (short-circuits so the  
two commands are connected directly)

 > ls | wc
 >        0       3     196

A little synchronization issue at this point....

Marcel





More information about the Squeak-dev mailing list