正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 15.7.21 and the binding of the name twice to this value will Defining a named procedure take place in this environment. Thus we add a pairing to the (lambda* (x*)(plus* x* x*)))GE) table of the symbol twice* and a pointer to this structure symbol ymbo Defining a named procedure Slide 15.7.22 (eva1’( define* twice So notice what has happened. We have created the ability to (lambda* (*)(plus* x* x*)))GE) create names for procedures in our environment, that point to one of these procedure objects. Thus we can now refer to that procedure object by name, thus building in a level of 卫1m包 abstraction 七w⊥ce★ 口[团 Slide 15.7.23 Implementation of apply (1) So let's look at the use of this abstraction, by looking at the evaluation of an expression that involves a name for one of these procedures. We want to see how eval and apply work together to unwrap the abstraction to more primitive First, let's evaluate the expression shown with respect to the global environment Implementation of apply (1) (eval '(twice* 4) GE) Eval will deduce that this is an application, thus reducing to (apply (eval ' twice* GE) this apply expression. We must evaluate the first (map (lambda (e)(eval e GE))'(4)) subexpression ( which we simply grab from the tree structure) and apply the result to the list we get by mapping eva l down the list of arguments in the initial expression. Note that all of these evaluations take place with respect to the same environment6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 15.7.21 ... and the binding of the name twice* to this value will take place in this environment. Thus we add a pairing to the table of the symbol twice* and a pointer to this structure. Slide 15.7.22 So notice what has happened. We have created the ability to create names for procedures in our environment, that point to one of these procedure objects. Thus we can now refer to that procedure object by name, thus building in a level of abstraction. Slide 15.7.23 So let's look at the use of this abstraction, by looking at the evaluation of an expression that involves a name for one of these procedures. We want to see how eval and apply work together to unwrap the abstraction to more primitive expressions. First, let's evaluate the expression shown with respect to the global environment. Slide 15.7.24 Eval will deduce that this is an application, thus reducing to this apply expression. We must evaluate the first subexpression (which we simply grab from the tree structure) and apply the result to the list we get by mapping eval down the list of arguments in the initial expression. Note that all of these evaluations take place with respect to the same environment
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有