正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 12.3.37 And remember what started all of this. That value then gets Example contd: (square y)Ie passed back out to where we were when we started this diagram, which is adding 1 to the value returned by this tnc-square procedure application, finally resulting in 17 There are a lot of details here, but the goal was to show how the o exactly the order in which to evaluate expressions, and how to P: K x s) b:(+1 look up the bindings of variables in the appropriate (square y)) environment in order to make sure expression has a legal value. I square Im=>#[compound! y In=>4 ( xx)gr 16)=>1 *|2=>#【prim]6mx2==>4 Lessons from the inc-square example Slide 12.3.38 EM doesnt show the complete state of the interpreter So here are the key points to take away from this example. The missing the stack of pending operations main point is to see how the rules for the environment model specify almost everything we need to know in order to The GE contains all standard bindings (*, cons, etc) understand how expressions are evaluated. It doesn't quite do all of it, in particular, it doesn't specify the pending opera Useful to link environment pointer of each frame as we saw in the last example The other two points to notice are summarized on the slide 4 6.001 Notes: Section 12. 4 Slide 12. 4 Example: make-counter Now that we are reasonably comfortable with the environment model, let's go back and tackle the problem that started us off Counter: something which counts up from a number this discussion. Remember this example from the beginning (define make-counter of lecture? (lambda ()(set! n ( n 1)) Counter, or something created by make-counter, was )) an object that should count up from a number. Every time we applied that procedure of no arguments, we would get as output the next number in sequence. We want to understand how evaluating this same expression could give rise to different (cb)=>2 ca and cb are independent values at different times. And how evaluating the same expression could give us different objects, with independent Let's see if the environment model helps explain this computation6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 12.3.37 And remember what started all of this. That value then gets passed back out to where we were when we started this diagram, which is adding 1 to the value returned by this procedure application, finally resulting in 17. There are a lot of details here, but the goal was to show how the rules of the environment model very mechanistically specify exactly the order in which to evaluate expressions, and how to look up the bindings of variables in the appropriate environment in order to make sure expression has a legal value. Slide 12.3.38 So here are the key points to take away from this example. The main point is to see how the rules for the environment model specify almost everything we need to know in order to understand how expressions are evaluated. It doesn't quite do all of it, in particular, it doesn't specify the pending operations, as we saw in the last example. The other two points to notice are summarized on the slide. 6.001 Notes: Section 12.4 Slide 12.4.1 Now that we are reasonably comfortable with the environment model, let's go back and tackle the problem that started us off on this discussion. Remember this example from the beginning of lecture? Counter, or something created by make-counter, was an object that should count up from a number. Every time we applied that procedure of no arguments, we would get as output the next number in sequence. We want to understand how evaluating this same expression could give rise to different values at different times. And how evaluating the same expression could give us different objects, with independent behavior. Let's see if the environment model helps explain this computation
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有