Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Curried functions

Reply
Thread Tools

Curried functions

 
 
=?ISO-8859-1?Q?Holger_T=FCrk?=
Guest
Posts: n/a
 
      06-04-2004

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

 
Reply With Quote
 
 
 
Reply

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



Advertisments