currying at language level (was: Re: add_command)

Thomas Heller theller at python.net
Mon May 13 16:02:41 EDT 2002


"Alex Martelli" <aleax at aleax.it> wrote in message news:mailman.1021316005.11846.python-list at python.org...
> It may be possible to offer all functionality in a way that turns
> out to be regular and simple enough, e.g.
IF we are already brainstorming, here are my thoughts:

> curry(f, Arg(1), Arg(0))
curry(f, Arg[1, 0])

> to swap the first two positional arguments,
> curry(f, 2, Arg())
curry(f, 2, Arg[:])
> to insert a 2 as 1st arg and shift all other args right by one,

> curry(f, 2, Arg(1:))
curry(f, 2, Arg[1:])

> to insert a 2 instead of the 1st actual arg (ignoring it) and leave
> all others alone, etc, etc.  That magical Arg thing could even be
> used plain rather than called to indicate "Arg(i) where i is the
> progressive number of this argument to curry after the callable",
> used as in "Arg(2, 'name')" to indicate that this may be passed
> as named argument ' name' alternatively, etc.
>

This class lets you play with this 'syntax':

class ARG:
    def __getitem__(self, magic):
        return magic

> Maybe, and maybe not.  We're talking of "signature adaptation".
> How far do we need to go?  How easy will it be to explain, how
> easy to use, how complete in its coverage of so-called-currying
> needs?  I don't think we have anywhere like complete
> understanding of this complicated set of issues.
>
>
> Alex
>
Thomas





More information about the Python-list mailing list