I have a function f: (a, b, c = 5, d = 0) -> {...} that takes between 2 and 4 arguments.
I want to pass a “bound” version of this function that always uses the defaults for the last arguments, but uses specific values (say 1 and 2) for the first two arguments. That is, I want g: () -> f(1, 2).
If I were to do partial application, I would get g': (c = 5, d = 0) -> f(1, 2, c, d). That is, partial application wouldn’t enforce the zero-argument nature of g that I desire, instead giving me g' which takes between 0 and 2 arguments.
What is the technique for getting g from f called, if anything?
Posting my comment as an answer: it seems that this question has little to do with functional programming or currying or partial application, but is instead precisely about taking a function that takes optional arguments that have defaults, and making a new function with no optional arguments in which the default arguments have been fixed.
Call this conceptual transformation
T. Assuming for some reason that partial application means that optional arguments remain optional (which need not be universal, but then again, the familiar functional programming languages — Haskell etc. — don’t even have optional arguments), there are at least two ways to getgfromf.f: (a, b, c = 5, d = 0) -> {....}which takes 2 to 4 arguments.T(f) : (a,b) -> {...}which takes exactly 2 arguments. That is,T(f)(a,b) = f(a,b) = f(a,b,5,0).g. That is,g() = T(f)(1,2) = f(1,2) = f(1,2,5,0).f: (a, b, c = 5, d = 0) -> {....}which takes 2 to 4 arguments.ffixing its first two arguments as 1 and 2, and call the resulting functiong'. That is,g' : (c=5, d=0) -> f(1, 2, c, d). It takes between 0 and 2 arguments.T(g) : () -> {....}which takes exactly 0 arguments. That is,T(g)() = g'() = g'(5, 0) = f(1, 2, 5, 0).In any case, the quandary in the question seems to hinge on
T, rather than any aspect of functional programming or currying or partial application. I don’t know ifThas enough of a point to have a standard name, but something like “fixing/binding default arguments” should be fine.