6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology Slide 13.1.9 One way of actually building such a system is to focus on the Dispatch on Type rows of the table, that is the operations. Indeed, our use of tagged data was based around this viewpoint, in which we Must change every generic operation Must keep names distinct created generic operations that handle the same operation for Adding new methods different data objects, and used the tag on the data object to Just create generic operations dispatch to the appropriate version of the procedure to handle that kind of data Data type 1 Data type 2 Data type 3 Data type 4 oc Some pro Some Operation 4 Some proc Some Some proc Some proc Dispatch on type Slide 13.1.10 Adding new data types But given this table, there is an alternative possible Must change every generic operation organization, which is around the columns of the table. This Must keep names distinct would focus on creating a generic data object that would know Adding new methods Just create generic operations how to handle different operations on that kind of data structure Data ty ata type 3Data type 4 proc Some proc me proc Some pr operation 4 Some proc ome proc/ Some proc Some pro Slide 13.1.1 Let's step back and rethink data. This sounds like an odd thing An Alternative View of Data Procedures with state to do but let's think about data in a very different way. Rather than thinking of data abstractions as some slots into which we A procedure has can put things, let's instead consider data to be a procedure with parameters and body as specified by n expression environment (which can hold name-value bindings some internal state This sounds strange! But, what is a procedure? It really has two parts: it has a set of parameters and a body which define the pattern of computation to perform as a function of the objects d in and as we saw in the environment model it has an associated environment which can hold name-value bindings, 4 60015e that is, pall of names and values6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. Slide 13.1.9 One way of actually building such a system is to focus on the rows of the table, that is the operations. Indeed, our use of tagged data was based around this viewpoint, in which we created generic operations that handle the same operation for different data objects, and used the tag on the data object to dispatch to the appropriate version of the procedure to handle that kind of data. Slide 13.1.10 But given this table, there is an alternative possible organization, which is around the columns of the table. This would focus on creating a generic data object that would know how to handle different operations on that kind of data structure. Slide 13.1.11 Let's step back and rethink data. This sounds like an odd thing to do but let's think about data in a very different way. Rather than thinking of data abstractions as some slots into which we can put things, let's instead consider data to be a procedure with some internal state. This sounds strange! But, what is a procedure? It really has two parts: it has a set of parameters and a body which define the pattern of computation to perform as a function of the objects passed in; and as we saw in the environment model, it has an associated environment which can hold name-value bindings, that is, pairings of names and values