HOM - Higher Order Messages

Francisco Garau francisco.garau at gmail.com
Tue Apr 18 21:25:40 UTC 2006


Hi,

During our first UK Smalltalk meeting, Marcel Weiher presented the ideas 
behind Higher Order Messages [1]. With them your collection code looks much 
nicer. Compare:

Without HOM:

    #(1 2 3) collect: [:e | e + 1]
    #(1 2 3) inject: 0 into: [:a :b | a + b]
    #(1 2 3) addAll: #(4 5)

With HOM:

    #(1 2 3) collect + 1
    #(1 2 3) reduce + 0
    #(1 2 3) add: #(4 5) all

Has anybody implemented them Squeak?
Marcel mentioned a port to VW, but he also mentioned that it is quite easy 
to implement.

The APL guys at the meeting where very excited about the #reduce message 
(which they denote by / ). They didn't like that you have to specifiy the 
initial value. I think that with some double dispatching, we could avoid 
having that initial value. We could have code like this: #(1 2 3) / +

Cheers,
Francisco

[1] http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf 




More information about the Squeak-dev mailing list