正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 12.3.10 (square 4)I Well. certainly doesn, t have a binding in the first frame of El. That frame came from the application of the procedure *: # prim object, and only formal parameters of the procedure are bound there. So our rule says to go up the enclosing environment pointer to the global environment and look for a binding in that environment We didn,'t tell you this, but in fact the global environment square >#lproc] creates a bindings for all the built-in procedures. Thus, is bound to the primitive multiplication procedure in that environment. Thus, our name rule looks up the value associated J with * and returns a pointer to this primitive procedure Slide 12.3.11 (square 4)I So in this case we do get a value associated with x *: #[prim] square: parameters: x square I GE==># [proc] (square 4)I gE Slide 12.3.12 Remember where we were. We were getting the values of the Ge=quare: N subexpressions of(* xx)with respect to El. We have the * #I prim] value of the first subexpression, so what about the value ofx with respect to El? This is just the name rule, so starting in El look for a binding of this variable. Of course, we find such a body (*x) binding in the first frame of el, so we get back the value square I GE ==># [proc] associated with x in that frame *n -> #[prim x6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 12.3.10 Well ... * certainly doesn't have a binding in the first frame of E1. That frame came from the application of the procedure object, and only formal parameters of the procedure are bound there. So our rule says to go up the enclosing environment pointer to the global environment and look for a binding in that environment. We didn't tell you this, but in fact the global environment creates a bindings for all the built-in procedures. Thus, * is bound to the primitive multiplication procedure in that environment. Thus, our name rule looks up the value associated with * and returns a pointer to this primitive procedure. Slide 12.3.11 So in this case we do get a value associated with *. Slide 12.3.12 Remember where we were. We were getting the values of the subexpressions of (* x x) with respect to E1. We have the value of the first subexpression, so what about the value of x with respect to E1? This is just the name rule, so starting in E1, look for a binding of this variable. Of course, we find such a binding in the first frame of E1, so we get back the value associated with x in that frame
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有