Partial functions

Currying is pretty wonderful :smiley: because it can be such a joy to use. For that, notation is super-important …

I like f[x,y] a bit more than I thought I would, although it’s limited in that you can only curry on the front arguments? But the notation is problematic. Square brackets are already used loads, and this clashes with e.g. Int8[1], which should according to the above notation return a 0-argument function.

As you saw Stefan commented,

I want to know that I called a function with the wrong number of arguments. I don’t want a function object where I expected a plain old result. This would also immensely complicate method dispatch, which is not acceptable from the implementation end. If you want to curry f(x,y), just write y->f(x,y) and it’s very clear what’s going on; it also doesn’t privilege the arguments based on their ordering — you can just as easily write x->f(x,y)

I think that’s a tight-looking lid on the problem. Since currying in practice is already very feasible via anonymous functions as above, with an easy, workable, clear syntax, it’s going to be pretty hard to find a spelling which is SO much better that it’s worth introducing that complexity without bringing a new capability.

2 Likes