As mentioned in Types and Programming Languages we can evaluate using either the call-by-value strategy or the call-by-name. For now only the call-by-value strategy is implemented. It might be an idea to implement both later on so one can see the different outcomes of the two. Evaluation strategies are further described here.
So as soon as fun1 is evaluated it will return a function that has both var a and var b in its closure. This might not seem useful, but I assure you that it is. Functions in functional languages, like the λ-calculus, have closures. Therefore we include this feature.
Closures are a clone of the current scope added whenever some term is reduced to an abstraction. That is when we bind an abstraction to some value during let-bindings or when substituting. Or if the final term returned is an abstraction.
There are two different kinds of scope strategies:
For now this version of λ-calculus only deals with static scoping. Dynamic scoping might be implemented as future work.
The call-by-value and call-by-name strategies was mentioned first in this chapter. Both strategies do not reduce within abstractions when the abstraction is not applied. We can list the two
Look for any under usage.