pipe

Andrew Tween amtween at hotmail.com
Sun Aug 26 21:24:31 UTC 2007


"Bert Freudenberg" <bert at freudenbergs.de> wrote in message 
news:4C5ECA16-978E-4250-B132-6A6CDF6442F2 at freudenbergs.de...
> 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

That's nice.
Yet another suggestion, similar to this - treat a pipe as having the same 
syntax as a cascade, but with a marker at the start.
e.g. (using ! as the pipe marker)
    ! 4 + 2; * 3; + 3; * 2

the blog posts example would be...

!db
    getBlogposts;
    filter: [ :blogPost | blogPost data < (today - 7 days)];
    filter: [ :blogPost | db coolPosts includes: item )];
    collectMails;
    do: [ :mail | "Happy to announce ..."]

Note that there is no problem having ! at the START of a statement.

So, a pipe is just '!' followed by a cascade.
Other chars, or sequence of chars, could be chosen instead of !
? / \ ` ? £ * % ~ @ ] } & + =  would all work,
but | ^ $ . # wouldn't work )
 





More information about the Squeak-dev mailing list