pipe

Fabio Filasieno fabio.filasieno at gmail.com
Sat Aug 25 21:57:41 UTC 2007


On Aug 25, 2007, at 7:05 PM, Joshua Gargus wrote:

>
> On Aug 25, 2007, at 6:17 AM, Fabio Filasieno wrote:
>
>>
>> obj message1: param
>>      | message2:param
>>      | message1: param
>>      | message2:param
>>      | message1: param
>>      | message2:param
>>      | message1: param
>>      | message2:param
>>      | message1: param
>>      | message2:param
>>      | message1: param
>>      | message2:param
>>
>> now some mix and match ...
>>
>> obj | send
>>        | left: a right:b
>>        | send | send | send
>>        | left: a right:b
>>        | message
>>
>> The pipe is needed to support a pipe&filter style of programming.  
>> That perfectly works with Smalltalk syntax, and truly
>> opens up a better way of doing functional transformations.
>>
>
> This all seems very hypothetical.  In what problem domain would you  
> end up writing code like this?  I've never written such code  
> myself, and I haven't seen anyone else write such code either.   
> Maybe that's just because people shy away from it because of all of  
> the parentheses, but I can't accept that without a real code  
> example to support it.
>
> Josh
>


a sequence of filter, map, fold, zip, ... it's extreamly common in  
any case you have to do quite some collection manipulation.

I don't know about other people, but I'll tell where I use it...

Selection, Projection, Cartesian Product, Union, Difference,  
Intersection are operators that I use a lot
in any data selection/manipulation context.

I use them as an "embedded SQL" on objective data.
You have persistent data in a file. You load the object graph. You  
query, delete, add, select data according to what results you get
from Selection, Projection, Cartesian Product, Union, Difference,  
Intersection.

Making easy to combine operators is not hypothetical ... the domain  
is the most popular: data selection and manipulation.
The first thing that comes to my mind is websites.

Example:

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

This kind of coding is extremely common ... the whole Python language  
is built around maps, tuples, list ...
an in Ocaml and Haskell too ... the list/map libraries with their  
zip, foldr, foldl, etx ... It's easy to think how you would use these  
kind functions
with the PIPE.




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070825/9a4cdc23/attachment.htm


More information about the Squeak-dev mailing list