Curried functions

  • Thread starter =?ISO-8859-1?Q?Holger_T=FCrk?=
  • Start date
?

=?ISO-8859-1?Q?Holger_T=FCrk?=

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top