pipe
Joshua Gargus
schwa at fastmail.us
Sun Aug 26 19:54:00 UTC 2007
On Aug 25, 2007, at 2:57 PM, Fabio Filasieno wrote:
>
> db getBlogposts
> | filter: [ :blogPost | blogPost data < (today - 7 days)]
> | filter: [ :blogPost | db coolPosts includes: item )]
> | collectMails
> | do: [ :mail | "Happy to announce ..."]
Thanks for the example. This is a very clean looking bit of code.
However, as others have noted, it's not fair to conclude that you've
won the argument after comparing it to:
((((db getBlogposts) filter: [ :blogPost | blogPost data < (today - 7
days)]) filter: [ :blogPost | db coolPosts includes: item )])
collectMails ) do: [ :mail | "Happy to announce ..."]
You can format the above so that it is very close to your example:
((((db getBlogposts
) filter: [ :blogPost | blogPost data < (today - 7 days)]
) filter: [ :blogPost | db coolPosts includes: item )]
) collectMails
) do: [ :mail | "Happy to announce ..."]
In my opinion, your code looks nicer for two reasons. You don't need
the initial parentheses, and '|' looks nicer to me than ')'.
However, it's been established that '|' is not available, so I tried
out your example with some of the other proposals from the thread.
db getBlogposts
` filter: [ :blogPost | blogPost data < (today - 7 days)]
` filter: [ :blogPost | db coolPosts includes: item )]
` collectMails
` do: [ :mail | "Happy to announce ..."]
db getBlogposts
$ filter: [ :blogPost | blogPost data < (today - 7 days)]
$ filter: [ :blogPost | db coolPosts includes: item )]
$ collectMails
$ do: [ :mail | "Happy to announce ..."]
db getBlogposts
;; filter: [ :blogPost | blogPost data < (today - 7 days)]
;; filter: [ :blogPost | db coolPosts includes: item )]
;; collectMails
;; do: [ :mail | "Happy to announce ..."]
The backtick is perhaps the cleanest-looking alternative, and it
doesn't have any conflicting associations with other Smalltalk syntax.
I don't like '$' very much... it looks very "heavy", and it looks a
lot like a character literal even though it has nothing to do with
them. I'm not sure how much we benefit by looking familiar to
Haskell programmers. <ducks and covers...> Probably not as much as
by adopting Java syntax to be familiar to the curly-brace crowd ;-) .
My favorite is ';;'. Most importantly, it shares both visual and
semantic similarity with the cascade operator, since both operators
affect the receiver of the subsequent message. Also, IMHO it looks
quite clean.
Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070826/bdff0ce2/attachment.htm
More information about the Squeak-dev
mailing list
|