Reinhold Birkenfeld wrote:
Steven Bethard wrote:
Chris Perkins wrote:
Random idea of the day: How about having syntax support for
currying/partial function application, like this:
func(..., a, b)
func(a, ..., b)
func(a, b, ...)

That is:
1) Make an Ellipsis literal legal syntax in an argument list.
2) Have the compiler recognize the Ellipsis literal and transform
  the function call into a curried/parially applied function.
So the compiler would essentially do something like this:

func(a, ...) ==> curry(func, a)
func(..., a) ==> rightcurry(func, a)
func(a, ..., b) ==> rightcurry(curry(func,a), b)

I haven't though this through much, and I'm sure there are issues, but
I do like the way it looks.  The "..." really stands out as saying
"something is omitted here".

The interaction of this with keyword args and omitted args is problematic (as is the case for rightcurry, in fact). I can't think of a good way to explain what _should_ happen for a function defined as def function(*args, **kwargs): ... when you:

    def fun(bug, frog, verb): ...
    f1 = function(1, ..., frog=3)
    f2 = f1(..., 4)
    f2()

Keywords were why I did no rightcurry definition in the first place;
I couldn't convince myself there was a good, obvious, resolution.

--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to