CS 15-212: Fundamental Structures of Computer Science II
The programming techniques used so far in the course have been, for the most part, "purely functional," although we have made some moderate use of exceptions for simple error handling. However many problems are most naturally addressed by keeping track of the "state" of an internal machine, which typically requires the use of mutable storage. ML supports mutable cells, or references, that store values of a fixed type. The value in a mutable cell can be initialized, read, and changed (mutated), and these operations result in effects that change the store. Programming with references is often carried out with the help imperative techniques, using functions solely for the way they change storage, rather than for their return values.