正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 12.3.21 Step three: take the formal parameter of this procedure and Example cont'd: (inc-square 4)I create a binding for it in the new frame to the value of the argument passed in tnc-square (square y)) Example contd: (inc-square 4)I gE Slide 12.3. 22 Step four: take the body of that procedure object and evaluate csquare: it with respect to this new environment, that is, ( 1 (square y)) with respect to E1 P: Y b:(*xx)b:(+1 (square y)) inc-square I Er=>#Icompound-proe..I ( 1 (square y))Ie 6001 SIC Slide 12.3.23 Again. notice how we have reduced the evaluation of one Example cont'd: (inc-square 4)I gE compound expression with respect to one environment to the Ge-ine-gquare evaluation of a simpler compound expression with respect to another environment As before, to evaluate this compound expression, we first need a the values of the subexpressions. The value of with respect top: chain from El to the global environment to get the primitive ?t b:(*xx b:(+1 El is determined by the name rule, chasing up the environmen (square y)) ine-square I G #[compound-pro ddition operation. The value of l is just a self-evaluation rule ( 1(square y))El 排【prim Example contd: (inc-square 4)I gE Slide 12.3.24 So all we have left to do is get the value of (square y) with respect to E1. This is again a compound expression,being evaluated with respect to this new environment b: (* xx) ind-square I cr >#Icompound-proc ..I quare y))I +|=>#[pxim El6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 12.3.21 Step three: take the formal parameter of this procedure and create a binding for it in the new frame, to the value of the argument passed in. Slide 12.3.22 Step four: take the body of that procedure object and evaluate it with respect to this new environment, that is, (+ 1 (square y)) with respect to E1. Slide 12.3.23 Again, notice how we have reduced the evaluation of one compound expression with respect to one environment to the evaluation of a simpler compound expression with respect to another environment. As before, to evaluate this compound expression, we first need the values of the subexpressions. The value of + with respect to E1 is determined by the name rule, chasing up the environment chain from E1 to the global environment to get the primitive addition operation. The value of 1 is just a self-evaluation rule. Slide 12.3.24 So all we have left to do is get the value of (square y) with respect to E1. This is again a compound expression, being evaluated with respect to this new environment
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有