pipe

danil osipchuk danil.osipchuk at gmail.com
Sun Aug 26 08:16:48 UTC 2007


2007/8/26, Cédrick Béler <cbeler at enit.fr>:

>
> actually, I've always find the pipe cool especially in linux but I don't
> find it obvious to understand... This said, I wouldn't mind having it in
> my image.
>
> What about using #=>. Is it already used (not in my image)? possible ?
>
> Cédrick

I think the subject should not be compared directly with unix pipes.
Unix pipes represent a way to reuse fixed parts of functionality -
compiled programs. These are black boxes. As a result application
logic for a shell script goes directly to the script itself which is
flat. Smalltalk is very different - you always can add behaviour you
need to the other object and the application logic is distributed
across the system. Long chains of unary selectors (analog for the
discussed operator) are often considered as a code smell because this
may put functionality to a wrong place. For instance, if one sees
something like "self myOrganization hrDivision currentHRManager
suggestApplicant" - he may consider to factor the code fragment to the
hrDivision class.

But there are cases when such chaining is obviously useful - I'm
personally annoyed by the excessive parenthesises (or looking for
shortcuts) while doing collection processing (that was one of the
examples) and also when I have to combine boolean messages, for
instance something like that:
((thingOne isSuch or: [thingTwo isThat]) and: [thing isNotEmpty]) or:
[self whatever]) ifTrue: [self doSomething] (assuming evaluating
operators don't work here). This example is not concrete of course but
I recall when I was frustrated having to write similar code.

cheers,
  Danil



More information about the Squeak-dev mailing list