Smatchcube's website 🌍


Exercise 3.20

Here is the environment structure after defining x and z:

Evaluation of (set-car! (cdr z) 17):

E3 is created during the call of set-car! then the arguments must be evaluated. (cdr z) is evaluated in E4 using passing-message style creating E5. After evaluating the arguments the 'set-car! message is passed in E6 and the set! procedure is called to change the value to 17.



Here is the environment structure after the call of (set-car! (cdr z) 17). It’s easy to see that (car x) returns 17.