Another solution is to simply copy the value of the variables into the closure at the time the closure is created. This will cause a different behavior in the case of mutable variables, because the state will no longer be shared between closures. But if it is known that the variables are constant, then this approach will be equivalent. The ML languages take this approach since variables in those languages are bound to values—i.e. variables cannot be changed. Java also takes this approach with respect to anonymous classes, in that it only allows one to refer to variables in the enclosing scope that are codice_1 (i.e. constant).