diff options
author | elioat <elioat@tilde.institute> | 2023-08-23 07:52:19 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2023-08-23 07:52:19 -0400 |
commit | 562a9a52d599d9a05f871404050968a5fd282640 (patch) | |
tree | 7d3305c1252c043bfe246ccc7deff0056aa6b5ab /js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note | |
parent | 5d012c6c011a9dedf7d0a098e456206244eb5a0f (diff) | |
download | tour-562a9a52d599d9a05f871404050968a5fd282640.tar.gz |
*
Diffstat (limited to 'js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note')
-rw-r--r-- | js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note new file mode 100644 index 0000000..161c88e --- /dev/null +++ b/js/games/nluqo.github.io/~bh/61a-pages/Lectures/3.2/env-note @@ -0,0 +1,44 @@ + A Note on Environments, frames, bindings, etc. + + +A frame is just a table. A variable is just an ENTRY (or place) in the +table. E.g., if we have a frame like this one + + x: 1 + y: 2 + +we can think of x and y as labelling the entries in the table, in which +are written 1 and 2. The places where 1 and 2 live are the variables. + +When we say that we bind or rebind the variable x, we mean that we +create an entry for it in new frame we are using to extend the +environment. "set!" simply puts a new value in the table entry +corresponding to a given name. + +All this terminology may be confusing because, in the book, they tend to +confuse variables and names. That is, they say ``create a new binding +for the variable x'', while it would be more accurate to say ``create a +new place (i.e., variable) named x and give it a value''. (Note that if +you just do a "set!", no one (including A&S) says that we have created a +new binding for x; rather, everyone would say that the binding has +changed. What's really changed is simply the value of the variable +(i.e., the value in the place) corresponding to x in the frame; the +association between x and this place remains unchanged. + +Similarly, when they say, ``the variable x is bound to 4 in this +frame'', it would be more accurate to say ``the new variable +corresponding to x in this frame has the value 4''. The difference is +that the first expression gives that impression that there is only one +variable x, and that it is rebound each time a function is called that +uses x as a formal parameter, whereas it is more accurate to say that +there are many variables corresponding to x, each one created when such +a function is called. + +It's important to emphasize that most of the time, the extensions to +environments that are created are thrown away after their use, i.e., +when the call to the function that created them finishes. This is +emphatically NOT the case when the call to a function returns a newly +created function. That is the one instance in which a frame will +persist, even though the function call that created it has ceased to +exist. + |