pipe

Yoshiki Ohshima yoshiki at squeakland.org
Fri Aug 31 02:16:02 UTC 2007


  Fabio,

> Smalltalk-80 lacks the concept of EASY "pipes" (chained functional applications) 
> as it is evident from the difference between
> 
> (((obj method:param1) method:param2) method:param3)
> and
> obj method:param1 | method:param2 | method:param3.
> 
> Smalltalk does't have EASY chained message sends .
> 
> To the daily programmers life means: either you do 
>   - collect:thenSelect:  -> This is a big source of bloat...
> or:
>   - ((obj collect:...) send: ...)   -> well... this is simply ugly and difficult write while prototyping
> 
> no other way in Smalltalk.
> 
> Smalltalk is  inconsistent too.
> 
> obj send1 send2 send3.
> 
> A perfect pipe. Is it ? Too bad that you can do only it sometimes not when you want.
> You can do it only if the method has no parameters.
> 
> This is a fact. No opinions. 

  Well, "easy or not" is an opinion.  Some have been in this saying
discussion that it is not "not easy".

  And, almost any language with more than one operator precedence
levels suffer from the same problem anyway.  If that language says
multiplication is stronger than addition, an expression like "3 + 4 *
5 + 6" will need parenthesis depending on how you like it to be
parsed.

  Do you like stack languages?

> I've shown how it's not just a syntax change. It will have a domino effect. It will change dramatically the whole
> language.

  What people have been asking for you was to show some examples in
Squeak where the programmer *avoided* using the collection protocol
(select:, collect:, do:, etc.) altogether, just because they didn't
want to put some extra parenthesis.  So far, your only examples are
collect:thenSelect: or fictional one like
message1:message2:message1:message2:....

  These collection protocol (with an Interval and collect: is almost
like the list comprehension) is widely used.  Some of the "whileTrue:"
and "whileFalse:" calls may be better replaced with these, but I can't
tell that today's code in Squeak lacks these functional style code.

> BTW, to the real functional programmer, programming is about function selection and function application. 
> It just happens that the `|` is traditionally used to separate pattern matching. But other characters could be used and
> have been proposed.
> To the eyes of a real functional what strikes most is the absence of an easy "function application" (not very precise
> thou, because smalltalk have objects and messaging)

  The syntax for a block (an anonymous function) in Smalltalk-80 is
more lightweight than Lisp's insistence of requiring "lambda", BTW.

> Putting the pipe is a HUGE change. It's like saying "Smalltalk is a functional programming language. By the way it's
> also an object oriented one".

  You know, the claim "Smalltalk is a functional programming language"
has been around long time.  And, the quintessence of typical
functional programming languages is not just chaining functions, I
think.  It is more about the higher level abstraction with (very)
higher order functions.  The Smalltalk library misses that aspect, but
introducing "pipe" wouldn't solve it.

  And, again, the word "pipe" definitely sounds like something to do
with multi processing.  If that was the proposal, I'd be more
interested.

> But my arguments are clear, logical, supported by history references
> and examples.

  Let us see how many readers agree with this...

> I'm sure you can do the the hard work of ignoring the capitalized words and exclamation marks as many are doing, and
> focus a bit more on the message that I'm trying to convey.

  I'm trying.

-- Yoshiki



More information about the Squeak-dev mailing list