正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 15.7.13 And that says that the evaluation of this expression returns thisImplementation oflambda* list structure. That is actually quite nice! We have created a new(eval'(lambda(x")(plus.x*I"))GE) object in our language, we have evaluated a lambda*and (x*)(plus (make-compound +(x*)'(plus* x* x*) GE created a procedure object. When we go to do an application(as (list ' compound '(x*),plus* x***)GE) we will see shortly)we need an expression represented as list structure so that we can pull out the pieces, and here they are All of the parts we will need for an application are represented as list structure within this list, so that we easily use those within the evaluator Implementation of lambda* Slide 15.7.14 (eva1(1 anda·(x*)(p1u·x*x*)c hus, this piece of list structure represents a procedure. It is our eval-1ambda.(lambda(**)(plus* g+ x*))Ge) particular way of creating a data structure for a procedure: it has compound'《x*} us★xtx)GE a tag identifying it as a compound procedure, a set of (list 'compound (**)(plus* x***)GE) parameters, and a body, all represented in the format we expect as a parsed tree 面中一 scm Slide 15.7.15 Defining a named procedure Now that we can create procedures in our interpreter, we (eval ,(define* twice* naturally want to give them names, and that just uses our (lambda* (E*)(plus* x* x*)))GE) define* expressions. How does this work? First of all, we will have some initial bindings in our environment Defining a named procedure Slide 15.7.16 as shown here in our abstract table representation for an (eval ,(define* twice (lambda* (x*)(plus* x* x*)))GE) environment. This environment includes prior bindings for might also have some other bindings based on builti We names to numbers and for symbols to boolean values procedures, for example, we may have installed a primitive twice procedure for plus大6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 15.7.13 And that says that the evaluation of this expression returns this list structure. That is actually quite nice! We have created a new object in our language, we have evaluated a lambda* and created a procedure object. When we go to do an application (as we will see shortly) we need an expression represented as list structure so that we can pull out the pieces, and here they are. All of the parts we will need for an application are represented as list structure within this list, so that we easily use those within the evaluator. Slide 15.7.14 Thus, this piece of list structure represents a procedure. It is our particular way of creating a data structure for a procedure: it has a tag identifying it as a compound procedure, a set of parameters, and a body, all represented in the format we expect as a parsed tree. Slide 15.7.15 Now that we can create procedures in our interpreter, we naturally want to give them names, and that just uses our define* expressions. How does this work? First of all, we will have some initial bindings in our environment ... Slide 15.7.16 ... as shown here in our abstract table representation for an environment. This environment includes prior bindings for names to numbers and for symbols to Boolean values. We might also have some other bindings based on built in procedures, for example, we may have installed a primitive procedure for plus*
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有