6.001 Structure and Interpretation of Computer Programs. Copyright o 2004 by Massachusetts Institute of Technology 6.001 Notes: Section 17.5 Slide 17.5.1 Streams-a different way of structuring Now, let's look at one example in which changing the computation evaluation model allows us to explore a very different kind of computational problem. Our goal is to show how a smal have a very different way of thinking about programs anet us change in the evaluator, basically our lazy evaluator, can let us Imagine that I want to simulate the motion of an object in a complex environment. A simple case might be a tennis ball that I throw against a set of walls. i would like to simulate how the ve】 ori ty elastici ball would bounce against those obstacles and where it might end up In our earlier approach, we might have chosen to model this using an object oriented system, which seems like a natural vay of breaking this problem up into pieces. Under that view, we would have a different object to represent each different structure in our simulation world. For example, we might have an object that represented the ball, with some internal state that captured the properties of the ball. Similarly each wall would be an object, perhaps witI fferent characteristics representing how objects bounce off them. And we might have a clock to synchronize interactions between the objects, leading to an object centered system very similar to what we saw in earlier lectures. In this way, each synchronization step would cause the objects to update their state, including detecting when, for example, two objects have collided so that the physics captured in each object would then govern changes in the state of the objects The thing to notice is that while this is a natural way of breaking up the system into units, the state of the simulation is basically captured in an instantaneous way. At any instant, we can determine the state of the overall stem by the values of the state variables of each object. But we don,'t have a lot of information about how the ystem has been evolving Said a different way, by breaking up this system into units of this form, we are naturally focusing on the discrete objects within the system, not on the behavior of the system6.001 Structure and Interpretation of Computer Programs. Copyright © 2004 by Massachusetts Institute of Technology. 6.001 Notes: Section 17.5 Slide 17.5.1 Now, let's look at one example in which changing the evaluation model allows us to explore a very different kind of computational problem. Our goal is to show how a small change in the evaluator, basically our lazy evaluator, can let us have a very different way of thinking about programs and programming. Imagine that I want to simulate the motion of an object in a complex environment. A simple case might be a tennis ball that I throw against a set of walls. I would like to simulate how the ball would bounce against those obstacles and where it might end up. In our earlier approach, we might have chosen to model this using an object oriented system, which seems like a natural way of breaking this problem up into pieces. Under that view, we would have a different object to represent each different structure in our simulation world. For example, we might have an object that represented the ball, with some internal state that captured the properties of the ball. Similarly each wall would be an object, perhaps with different characteristics representing how objects bounce off them. And we might have a clock to synchronize interactions between the objects, leading to an object centered system very similar to what we saw in earlier lectures. In this way, each synchronization step would cause the objects to update their state, including detecting when, for example, two objects have collided so that the physics captured in each object would then govern changes in the state of the objects. The thing to notice is that while this is a natural way of breaking up the system into units, the state of the simulation is basically captured in an instantaneous way. At any instant, we can determine the state of the overall system by the values of the state variables of each object. But we don't have a lot of information about how the system has been evolving. Said a different way, by breaking up this system into units of this form, we are naturally focusing on the discrete objects within the system, not on the behavior of the system