High Order Messages in Python

Jp Calderone exarkun at divmod.com
Sat Oct 22 18:37:19 EDT 2005


On 22 Oct 2005 15:11:39 -0700, "eduardo.padoan at gmail.com" <eduardo.padoan at gmail.com> wrote:
>Hum... I thnk you dont get the ideia: I'm not talking abou High Order
>Functions.
>What ho call "High Order Methods is some like "connecting" some
>'generic' methods created to do things like this:
>    claimants.where.retired?.do.receive_benefit 50
>The 2nd and 3rd links that in the first post is the most relevant to
>undestand the concept. Read this too:
>http://www.metaobject.com/papers/Higher_Order_Messaging_OOPSLA_2005.pdf

These are just more involved applications of the same idea.  They're easily implemented in Python, using primitives such as HOF, if one desires.

However, I don't see why one would want to write the above mish-mash, rather than:

    for cl in claimaints:
        if cl.retired():
            cl.receive_benefit(50)

Or:

    [cl.receive_benefit(50) for cl in claimaints if cl.retired())

Or:

    map(
        ClaimaintType.receive_benefit,
        filter(
            ClaimaintType.retired,
            claimaints),
        itertools.repeat(50))

Or:

    claimaintGroup.disburse()

Jp



More information about the Python-list mailing list