CS 227 Lecture -*- Outline -*- * Introduction to Part 3: Managing State. We now start to discuss the imperative programming style. So far what we have done is called functional (or applicative) style. expressions only, nothing changing if we want to model something changing, we have to pass it around Remember the change-making problem? In imperative programming, every procedure has an implicit argument which is the state of the entire program can change that state by using vector-set! (Ch 9) and set!, set-car!, set-cdr! (Ch 11). Imperative programming is by far the most widely used style of programming. (If you have programmed before, you have seen some of it.) It is an essential part of each programmer's tool kit. Neat thing about this is how it mixes with the functional programming ideas we saw in chapter 7. The combination has great power. We call this "mostly functional programming" after H. Baker. If we have time, will see how to use that power to do object-oriented programming (Ch. 12). ** Vectors Chapter 9 introduces vectors. These allow constant time access to the elements. They can also be updated in constant time. (Like arrays in other languages.) ** Mutation Chapter 11 applies the idea of changing state, mutation, to variables and lists. (Changing the state of a variable is called assignment.) ** Object-oriented progrmming Chapter 12, which we may not get to, describes a combination of higher-order process (as in Chapter 7) and state change: OOP.