pipe

Igor Stasenko siguctua at gmail.com
Sat Aug 25 05:08:53 UTC 2007


On 25/08/07, Matthew Fulmer <tapplek at gmail.com> wrote:
> On Sat, Aug 25, 2007 at 05:39:17AM +0300, Igor Stasenko wrote:
> > > > I need the `|` to avoid parenthesis, and weird hacks ...
> > >
> > > Like what?
> > >
> > > What do you mean by pipes? Are you refering to some kind of
> > > streaming like in bash where output can be generated from one
> > > process and input to another with finite memory? If so, I am not
> > > sure that is possible in general; objects are not always
> > > serializable.
> > >
> > > What kind of use case do you have in mind?
> > >
> > let me elaborate:
> >
> > a message1 | message2
> >
> > is equal to:
> >
> > a message1 message2
> >
> > and:
> >
> > a message1: param | message2: param2
> >
> > is equeal to:
> >
> > (a message1: param) message2: param2
> >
> >
> > and as you can see writing code with so-called 'pipes' makes code much cleaner
>
> Those two examples are exactly the same length in characters, so
> I don't see what metric qualifies one as much cleaner than the
> other.
>

try write following using pipes and see the difference. The point is
not a number of characters , but how easy you can read the code:

(((a message1: param1) message2:param2) ifTrue: [ b ] ifFalse: [ c ])
message3:param3


> Parenthesis are not very common in squeak, and this would be
> less common as parenthesis. Parentheses are more general
> too; you could not do this with pipes:
>
> dict at: (self keyFor: anItem) put: 3
>
no, you can't do this with pipes. pipes is like a cascade, but with
same message passing semantics like regular continuation and allow you
to mix binary or keyword messages in one continuation without using
parenthesis:

a + b | mixWith: c | squared + 5



> I am really missing what the point of this is
>
> --
> Matthew Fulmer -- http://mtfulmer.wordpress.com/
> Help improve Squeak Documentation: http://wiki.squeak.org/squeak/808
>
>


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list