Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Curried functions

Thread Tools

Curried functions

Posts: n/a


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 ()
fn (*argl, **argd)
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 ()
fn (*argl, **argd)
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?



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Curried class methods? Scott Lamb Python 3 08-17-2006 09:15 PM
Shared functions vs Non-Shared Functions tshad ASP .Net 11 05-27-2005 05:53 PM
please help me in distinguish redefining functions, overloading functions and overriding functions. Xiangliang Meng C++ 1 06-21-2004 03:11 AM
Exportable class functions as stand alone functions to .DLL or .SO Timothy Wong C++ 3 05-20-2004 01:44 PM
Curried functions in JavaScript (how to employ genericly, and invisibly)? svend Javascript 6 07-25-2003 02:42 AM