HOM - Higher Order Messages
Klaus D. Witzel
klaus.witzel at cobss.com
Fri Apr 21 04:42:18 UTC 2006
Hi Jon
on Thu, 20 Apr 2006 14:50:20 +0200, you <jon at huv.com> wrote:
> On Thu, 20 Apr 2006 07:40:39 +0200, "Klaus D. Witzel"
> <klaus.witzel at cobss.com> wrote:
>
>> newArray #at: eachOf: (1 to: n) #put:
>> withEach: oldArray onlyIf: [:index :element | element notNil]
>
> This is supposed to be more readable (and higher-order) than normal
> Smalltalk syntax?
>
> newArray := oldArray select: [:each | each notNil]
>
No. Since it was explicitly asked for the first n elements, the correct
translation is
(1 to: n) with: oldArray do: [:index :each |
each notNil ifTrue: [newArray at: index put: each]]
I believe that a good syntax coloring would help HOM off the ground and,
as the example shows, helps saving message selectors and nesting of blocks.
But also and for sure, every good thing has its counterexamples ;)
/Klaus
More information about the Squeak-dev
mailing list
|