正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Evaluation in the environment model Slide 12.1.16 Now we are ready to see how to connect environments to All evaluation occurs in an environment evaluation. First, as we have already suggested, all evaluation is The current environment changes when the going to take place with respect to some environment. The environment will provide the context for how to interpret symbols and names. Notice that this won't al ways be the same environment, and a key issue is that whenever we apply a procedure, we will create a new environment, which captures he context for interpreting the variables of that procedure 6 001 SICP Slide 12.1.17 Evaluation in the environment model We have said that all evaluation of expressions is going to take place with respect to an environment. And we have also seen All evaluation occurs in an environment that environments can inherit other environments as part of the interpreter applies a procedure chaining process. Nonetheless, this means that eventually we have to terminate that chaining of environments, and to do that The top environment is called the global environment(GE) we have a special environment, called the global environment Only the gE has no enclosing environment It has no enclosing environment and is the only such environment with that property. This is the environment in which we will normally evaluate expressions, as it is our starting point. It is also going to hold the bindings for our basic| 4 6001S expressions in our language Evaluation in the environment model Slide l2.1.18 So we are ready to start putting together rules for evaluating All evaluation occurs in an environment The current environment changes when the expressions with respect to an environment. Before we do, lets terpreter applies a procedure remind you that our central rule for evaluation deal with combinations, and in this new model things are nearly the same top environment is called the global environment(GE) as they were in the substitution model ly the GE has no enclosing environment As before, we will evaluate the subexpressions in any order To evaluate a combinatio Evaluate the subexpressions in the current environment now with respect to the current environment. Then we will ply the value of the first to the values of the rest apply the value of the first subexpression to the values of the others. We will see shortly how to do that in a very mechanis 6 001 SICP I way. With all of this in place, lets start actually building tfo stic environment model 6.001 Notes: Section 12.26.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 12.1.16 Now we are ready to see how to connect environments to evaluation. First, as we have already suggested, all evaluation is going to take place with respect to some environment. The environment will provide the context for how to interpret symbols and names. Notice that this won't always be the same environment, and a key issue is that whenever we apply a procedure, we will create a new environment, which captures the context for interpreting the variables of that procedure. Slide 12.1.17 We have said that all evaluation of expressions is going to take place with respect to an environment. And we have also seen that environments can inherit other environments as part of the chaining process. Nonetheless, this means that eventually we have to terminate that chaining of environments, and to do that we have a special environment, called the global environment. It has no enclosing environment and is the only such environment with that property. This is the environment in which we will normally evaluate expressions, as it is our starting point. It is also going to hold the bindings for our basic expressions in our language. Slide 12.1.18 So we are ready to start putting together rules for evaluating expressions with respect to an environment. Before we do, lets remind you that our central rule for evaluation deal with combinations, and in this new model things are nearly the same as they were in the substitution model. As before, we will evaluate the subexpressions in any order, now with respect to the current environment. Then we will apply the value of the first subexpression to the values of the others. We will see shortly how to do that in a very mechanistic way. With all of this in place, lets start actually building the environment model. 6.001 Notes: Section 12.2
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有