# What is the practical use of the form g[x][y][z]?

Consider two functions, f and g. f is a curried function. It takes a single argument and returns another function. It seems that f and g are similar. However, their behaviours are quite different.

I want to know the practical use of g[x][y][z], and under what circumstances I should use it.

In:

Clear[f, g]
f[x_] := y \[Function] z \[Function] x + y + z
f[x]
f[x][y]
f[x][y][z]

g[x_][y_][z_] := x + y + z
g[x]
g[x][y]
g[x][y][z]


Out:

Function[y$, Function[z$, x + y$+ z$]]
Function[z$, x + y + z$]
x + y + z

g[x]
g[x][y]
x + y + z


Derivative is like g. It isn't a typical example. I guess most of people use the operator ('), but not the general form Derivative[n1,n2,...][f].

This question is inspired by the snippet of ClangCompiler.m.

ClangCompiler[method_][args___] :=
CCompilerDriverCCompilerDriverBaseBaseDriver[method][args]


After I went through CCompilierDriverBase.m, it seems that this form is like an association.

BaseDriver["OptionsExceptions"]["CreateLibrary"] := {"MprepOptions"}

BaseDriver["OptionsExceptions"]["CreateExecutable"] := {"LibraryType"}

BaseDriver["OptionsExceptions"]["CreateObjectFile"] :=

If I interpret the question as "what can g-type functions do that f-type can't", I think it's similar to asking why one would want to use SetDelayed rather than Set together with Function. You can a lot of things with h=Function[...], but it can still be more elegant/useful to use h[...]:=.... Then there are things like foo[x_EvenQ]:=bar[x] that leave foo unevaluated. It's also easier to add more definitions later with SetDelayed.