Closures are used to implement continuation-passing style, and in this manner, run-time, when the outer function executes, a closure is formed, consisting of the inner function s code and references ( the upvalues ) to any variables of the outer function required by the closure.
12.
(The value of a "'let "'- expression is that of the expression between "'in "'and "'end "'. ) The encapsulation of an invariant-preserving tail-recursive tight loop with one or more accumulator parameters inside an invariant-free outer function, as seen here, is a common idiom in Standard ML, and appears with great frequency in SML code.