I like the idea of a pipe operator just like I like the ';' operator.<br>They are both (and independently) useful.<br>However, I object to using the '|' symbol for this. <br>(How about using '::' or ':-:' instead?)
<br><br>I think the '|' operator should be used to plug output streams into input streams<br>just as it is used between processes in linux shells.<br><br>To use such an operator we first we need objects<br>that (in the most general case)
<br>read data from an input stream, process the stream, <br>and then output the
result to an output stream. <br>Let b1, b2, b3 be three such objects, 'in' be an input stream,<br>and 'out' be an output stream.<br>Then we could write:<br><br>b1 < in; > out. <br><br>to have b1 read its input from 'in' and put its result into 'out'.
<br>Note that 'b1 < in' cannot generate any output since b1 does not yet know<br>where to send it. After the '; > out.' b1 can process its input and put its<br>output into 'out'.<br><br>
Now we can write:<br><br>b1 < in; | b2 | b3 > out.<br><br>which has <br>b1 read its input from 'in', process its input, and send its output to b2,<br>b2 process its input (the output of b1) and send its output to b3, and
<br>b3 process its input (the output of b2) and put its output into 'out'.
<br><br>To have this work well there would need to be objects called pipes<br>that do most of the data moving between b1, b2, b3.<br>Thus the method '|' would look something like:<br><br>| b<br>pipe := Pipe output: b.
<br>self > pipe.<br><br>Perhaps things would not work exactly as I have described<br>but you get the idea.<br>Suggestions as to better syntax welcome.<br><br>Notes:<br>1) No change to Squeak or any other version of Smalltalk is needed.
<br> (unless we want cleaner syntax);<br> we only need to implement this feature. <br> Anybody want to write a pipes package?<br> Given how useful pipes are in linux shells, <br> it surprises me that a pipes package hasn't been written before.
<br>2) Some collection classes could be made to act like streams with regard to pipes;<br> we just need to implement the necessary methods.<br>3) Class Pipe could have subclasses each of which would have different internal
<br> implementations for efficiency reasons.<br><br>Ralph Boland<br>