Pipe syntax and the current methods
Alan Lovejoy
squeak-dev.sourcery at forum-mail.net
Mon Aug 27 19:49:37 UTC 2007
Michael Lucas-Smith wrote:
> It's not like you even need a new syntax to avoid the paranthesis -
> just new kinds of objects, eg:
>
> nonHermsOlderThanTensMothersNames := lotsOfPeople selecting: [:each |
> each age > 10]; rejecting: [:each | each sex = #unknown]; collecting:
> [:each | each mother]; selecting: [:each | each notNil]; collecting:
> [:each | each name]; asOrderedCollection
>
> No new syntax, just new objects. Has this already been covered in the
> thread? if so, sorry for bringing it up again.
>
But it's not fully equivalent.
Adding new methods that return results (and not self) must be done at
least once per selector--and requires a naming convention that
associates the "return receiver" with the "return result" version of
each selector (and there would be many cases where the distinction
wouldn't matter.)
Adding a new "Pipe" class (e.g., as in Bert's "Squeak asPipe" example)
results in an implementation that isn't thread safe (if the Pipe object
isn't private to a single thread.) And it's not as efficient as
syntax-based piping.
The pipe operator is a single, always thread-safe, efficient change. But
that doesn't mean I endorse it. I am still considering the matter.
More information about the Squeak-dev
mailing list
|