SICP Exercise 4.13 make-unbound!

Exercise 4.13.  Scheme allows us to create new bindings for variables by means of define, but provides no way to get rid of bindings. Implement for the evaluator a special form make-unbound! that removes the binding of a given symbol from the environment in which the make-unbound! expression is evaluated. This problem is not completely specified. For example, should we remove only the binding in the first frame of the environment? Complete the specification and justify any choices you make.

SOLUTION

I decided to remove only the binding in the first frame of the environment. The same variable
could be bound to different values in different frames and if we remove the variable from all
frames, then it can cause unexpected behaviors in other procedure executions.

The code and tests are here.

Comments

Popular posts from this blog

SICP Exercise 2.56 differentiation rule

SICP Exercise 1.28 (Miller-Rabin Test)

SICP Exercise 4.18 a alternative strategy for interpreting internal definitions