Curried functions

Discussion in 'Python' started by =?ISO-8859-1?Q?Holger_T=FCrk?=, Jun 4, 2004.

  1. Hello,

    a common pattern to write curried functions (i.e. without the
    need for a special partial application syntax, like in PEP 309)
    is like in this example:

    def functionLock (lk):
    def transform (fn):
    def lockedApply (*argl, **argd):
    lk.acquire ()
    try:
    fn (*argl, **argd)
    finally:
    lk.release ()
    return lockedApply
    return transform

    PEP 318 (decorators) contains some other examples.
    I wonder if someone else than me would appreciate a syntax
    like this:

    def functionLock (lk) (fn) (*argl, **argd):
    lk.acquire ()
    try:
    fn (*argl, **argd)
    finally:
    lk.release ()

    It would even enable us to write curried function definitions
    like this one:

    def f (*a) (x=1, **b) (*c, **d):
    [...]

    Current approaches about currying or partial application
    can't handle the latter in a simple/transparent way.

    Will it be hard to implement the feature?
    Are there any reasons that this syntax/concept is a bad idea?

    Greetings,

    Holger
     
    =?ISO-8859-1?Q?Holger_T=FCrk?=, Jun 4, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    11
    Views:
    839
    tshad
    May 27, 2005
  2. Timothy Wong
    Replies:
    3
    Views:
    428
    Timothy Wong
    May 20, 2004
  3. Xiangliang Meng
    Replies:
    1
    Views:
    1,645
    Victor Bazarov
    Jun 21, 2004
  4. Scott Lamb

    Curried class methods?

    Scott Lamb, Aug 17, 2006, in forum: Python
    Replies:
    3
    Views:
    390
    Scott Lamb
    Aug 17, 2006
  5. svend
    Replies:
    6
    Views:
    152
    Dom Leonard
    Jul 25, 2003
Loading...

Share This Page