正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 15.7.35 For the purposes of this exposition, we can just choose to Implementation of environment model represent an environment as a list of tables. We will use the Environment list<table> table abstraction, as before (which we know we can implement in terms of list structure), and an environment will just be a list of these tables, sequenced together mplementation of environment mod Slide 15.7.36 Environment list<table> So, for example, given this abstract representation for the environment as a nested chain of tables starting with frame a name value as a table, scoped by the global environment which is also a table, we can simply represent this much more concretely as 4 Slide 15.7.37 Implementation of environment model this list structure. Now an environment points to a list, the Environment s liststable> first element of which is the first frame the second element of which points to the remaining list of tables, which might be value arbitrarily long. Eventually, the list will terminate in the global environment, which will contain the bindings for all the things that are established in the installation of the original environment. This is one way of representing an environment hain, which clearly illustrates the chaining together of frames name value (primitive # add]) In sequence greater*(primitive #igrt]) Slide 15.7.38 Here is the code to actually implement environments. Most of this is bookkeeping detail, using lists am计(, Creating the initial global environment is simply a matter of starting with an empty environment, and then building a new frame that creates pairings of names for built in procedures with the actual representations of the primitives6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 15.7.35 For the purposes of this exposition, we can just choose to represent an environment as a list of tables. We will use the table abstraction, as before (which we know we can implement in terms of list structure), and an environment will just be a list of these tables, sequenced together. Slide 15.7.36 So, for example, given this abstract representation for the environment as a nested chain of tables starting with Frame A as a table, scoped by the global environment which is also a table, we can simply represent this much more concretely as ... Slide 15.7.37 ... this list structure. Now an environment points to a list, the first element of which is the first frame, the second element of which points to the remaining list of tables, which might be arbitrarily long. Eventually, the list will terminate in the global environment, which will contain the bindings for all the things that are established in the installation of the original environment. This is one way of representing an environment chain, which clearly illustrates the chaining together of frames in sequence. Slide 15.7.38 Here is the code to actually implement environments. Most of this is bookkeeping detail, using lists. Creating the initial global environment is simply a matter of starting with an empty environment, and then building a new frame that creates pairings of names for built in procedures with the actual representations of the primitives
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有