Hi Fabio,
welcome to the list! I guess what you would express with pipes would be written in Smalltalk like this?
(((obj collect: [ :x | …]) filter: [:x | …] ) select: [:x | …])
And with a pipe operator you would save a few parntheses here?
With unary message sends, the syntax gives you a kind of piping for free, just chain the messages:
'abc' reverse first isVowel
With keyword messages the syntax is in favor of multiple keyword message selectors:
'abc' detect: [:a | a isVowel] ifAbsent: ['']
is the message #detect:ifAbsent: and not a cascade of two messages #detect and #ifAbsent.
Smalltalk syntax was deliberately designed to be simple, based on a few mechanisms. By the way, your pipe idea is reflected in some methods in the collection hierarchy:
Collection>>select:thenDo: Collection>>select:thenCollect:
Cheers
Matthias
On 8/24/07, Fabio Filasieno fabio.filasieno@gmail.com wrote:
II'm new at Smalltalk and I have a few questions. """Why smalltalk has no operator for piping ?""""
obj collect: [ :x | …] | filter: [:x | …] | select: [:x | …] ?
but has the `;` (cascade operator)?
I don't care to send messages to the reciever of the previous message, because I return self when no return value is important; for instance ….
point x: 10 | y: 20 | z: 30
x returns self, y returns self, z returns self -> which is the updated point.
works exactly as:
point x:10; y:20 ; z:30.
But you lose PIPES !!!!! Can somebody elaborate on this ?
There might be cases where I'm returning a value and I wish to discard it and then send again to the previous receiver ... but I really don't like to loose the pipe for that ... since I can do that returning self.
With Smalltalk ... we've got a homoiconic language and the system written in it self, a consistent language in everything, even the if- then-else that everybody else still don't get right; we've got the most wonderful programming experience of all, even better that Ruby/ Python etc ...
but why on earth we have the "cascade operator" instead of the PIPE ????? What I'm I missing ?
I need the `|` to avoid parenthesis, and weird hacks ...
Fabio