This is a performance hack to avoid the cost of a partial application in the expected use case mentioned in the comment.
OCaml compiles curry functions in a fixed structure using closure to partially apply it where necessary. This means that the challenges of this reality are effective - there is no closure construct, just a function call.
compose for fun x -> f (gx) will be building a closure, but it will be more efficient than a partial application. Closures created by a partial application go through the caml_curryN shell, which exists to ensure that effects occur at the right time (if this closure is partially applied).
The fixed arity that the compiler chooses is based on simple parsing — essentially, how many arguments are taken in a string without any intermediate. Programmers Jane St. used this to select the desirability they desire by entering () "between the arguments.
In short, let compose fgx = f (gx) is a less desirable definition because it will make the general argument with two arguments compose fg be a more expensive partial application.
Semantically, of course, there is no difference.
gsg
source share