正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 12. 6 (define ca (make-counter 0))Ige Right! It points to El, because this is the environment in which we were evaluating the lambda expression. Notice that this make-counter: is a different structure than we have seen before For the first time, we have a procedure object whose environment pointer Q points to a frame or environment other than the global environment And in a second we are going to see why that b: (lambda ( points to E1 because the lambda (+n1 ))n)I Slide 12.4.7 (define ca (make-counter 0))I ge Now remember, that red(that double bubble)is the value actually returned by the evaluation of the body of the procedure make-counter we applied So that is the value returned by (make counter 0).Therefore, we can complete our definition.& The binding for ca up in the global environment, since that is p where we were evaluating the define, is now created, and b: atda 2) because the lambda that variable points to the object returned by applying make was evaluated in E1 counter, which is that procedure object b:(set! n ( n 1))n This is a useful structure. The variable ca. which is available (lambda ()(set! n ,n-1))n)IE to us in the global environment, points to a procedure, much as earlier things did, but this procedure has nested within it an internal environment. Its environment pointer points to an environment that is scoped relative to the global environment Slide 12.4. 8 So having created this procedure object associated with ca let's look at what happens when we apply it, when we evaluate it with no arguments 601 SICP6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 12.4.6 Right! It points to E1, because this is the environment in which we were evaluating the lambda expression. Notice that this is a different structure than we have seen before. For the first time, we have a procedure object whose environment pointer points to a frame or environment other than the global environment. And in a second we are going to see why that is crucial. Slide 12.4.7 Now remember, that red (that double bubble) is the value actually returned by the evaluation of the body of the procedure we applied. So that is the value returned by (make￾counter 0). Therefore, we can complete our definition. The binding for ca up in the global environment, since that is where we were evaluating the define, is now created, and that variable points to the object returned by applying make￾counter, which is that procedure object. This is a useful structure. The variable ca, which is available to us in the global environment, points to a procedure, much as earlier things did, but this procedure has nested within it an internal environment. Its environment pointer points to an environment that is scoped relative to the global environment. Slide 12.4.8 So having created this procedure object associated with ca, let's look at what happens when we apply it, when we evaluate it with no arguments
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有