-
Notifications
You must be signed in to change notification settings - Fork 4
Uncurry optimization #24
Description
Scilla's semantics for function applications follows currying semantics.
i.e., when we have let foo = fun (a : Int32) => fun (b : Int32) => ... and an application foo a b, then it is evaluated as "apply a to foo to get function, and b is applied to this result function". In the case of foo never being applied partially, we should replace the curried functions with a single function that takes two arguments fun (a : Int32, b : Int32).
PR #25 defines types and AST to accommodate functions (and function types) that take multiple arguments. Passes after it (ex: closure conversion) are already designed to work on functions with multiple arguments (and type applications having non-currying semantics).
Therefore, an optimization is needed to combine curried functions without partial application uses.
This requires
- An analysis to figure out which functions aren't partially applied.
- Combine the function
funs into a single definition taking multiple arguments. - Combine
Appsequences (which represent a sequence of partial applications: see Explicitize partial applications of functions. #23, Define an AST with no currying semantics and translate to it #25 ) into anAppwith multiple arguments.
The transformation can likely be written in Uncurry.ml, after the translation into Uncurried_Syntax.