正在加载图片...
6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology 6.001 Notes: Section 8.1 Slide 8.1.1 Review: data abstraction In this lecture we are going to introduce a new data type, a data abstraction consists of: specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything we have done so far in the course has focused on procedures to manipulate selectors numbers. While we have used names for things, we have treated them as exactly that: names associated with values Today we are going to create a specific data type for symbols and see how having the notion of a symbol as a unit to be contract manipulated will lead to different kinds of procedures To set the stage for this recall what we have when we deal with 60015e data abstractions. We said a data abstraction in essence consisted of a constructor (for building instances of the abstraction), selectors or accessors(for getting out the pieces of an abstraction), a set of operations(for manipulating the abstraction, while preserving the barrier between the use of the abstraction and the internal details of its representation), and most importantly, a contract(specifying the relationship between the constructor and selectors and their behaviors) Review: data abstraction Slide 8.1.2 a data abstraction consists of For example, if I want to create an abstraction for manipulating constructors points in the plane, I could create a constructor like this Make mbda (x y) (list x y))) point is a procedure that glues together two parts into a list operations contract Slide 8.1.3 eview ta abstraction Here is one of the associated selectors which in this case takes a data abstraction consists of a data object as built by the constructor, and pulls out the first constructors (or x coordinate) part of that object (lambda (x y) (list x y))) (lambda (pt) t})) operations6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. 6.001 Notes: Section 8.1 Slide 8.1.1 In this lecture we are going to introduce a new data type, specifically to deal with symbols. This may sound a bit odd, but if you step back, you may realize that everything we have done so far in the course has focused on procedures to manipulate numbers. While we have used names for things, we have treated them as exactly that: names associated with values. Today we are going to create a specific data type for symbols, and see how having the notion of a symbol as a unit to be manipulated will lead to different kinds of procedures. To set the stage for this, recall what we have when we deal with data abstractions. We said a data abstraction in essence consisted of a constructor (for building instances of the abstraction), selectors or accessors (for getting out the pieces of an abstraction), a set of operations (for manipulating the abstraction, while preserving the barrier between the use of the abstraction and the internal details of its representation), and most importantly, a contract (specifying the relationship between the constructor and selectors and their behaviors). Slide 8.1.2 For example, if I want to create an abstraction for manipulating points in the plane, I could create a constructor like this. Make￾point is a procedure that glues together two parts into a list. Slide 8.1.3 Here is one of the associated selectors, which in this case takes a data object as built by the constructor, and pulls out the first (or x coordinate) part of that object
向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有