pipe

Jason Johnson jason.johnson.081 at gmail.com
Sat Aug 25 18:40:02 UTC 2007


On 8/25/07, Fabio Filasieno <fabio.filasieno at gmail.com> wrote:
>
> check this out ...
>
> (((((((((((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

This is a bit contrived.  If you ever did find the need to do this it
should look like:


(((((((((((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

Code smell to be sure, but you pile what you don't like on one line
and say you can't read it while formatting what you do like and saying
"see!".

> 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.

pipe&filter style of programming?  Most people call this "functional
programming" and it doesn't require a pipe operator to work.  Such an
operator can make certain code cleaner to be sure, but it doesn't
"open up a better way of doing functional transforms" by any means.
Just saves you one character per function call.

>  >>>>>>>>> cascade is useless <<<<<<<<<<<<
>
> because it's redundant :
>
> Example :
>
> point x:10; y:10; z:10.
>
> Your could write in fact.
> (((point x:10) y:10) z:10)
> since x:10 returns self anyway, y:10 returns self anyway and z:10 returns
> self anyway.

In this case yes, one could use parenthesis, the cascade operator or a
new statement delimiter (which you call "pipe").  But sometimes you
wish to send a bunch of messages to an object that may not return
self.

> With the pipe I removed parenthesis from much wider selection of cases, I
> enable a cleaner way of writing functional transformations, and therefore
> it's a better design.

You don't have a conflict between cascade and your "pipe" unless you
want to use the ; symbol.  Cascade is a special message that causes
the compiler to put in some op codes for duplicating the cascaded
object on the stack.  What you want is just the current behavior
without needing the parenthesis to disambiguate.  I don't think it
would be too hard to add a new symbol that has the compiler treat it's
left side the same as it would if the statement was in parenthesis.



More information about the Squeak-dev mailing list