CS 15-212: Fundamental Structures of Computer Science II |
We introduce declarations which evaluate to environments. An environment collects a set of bindings of variables to values which can be used in subsequent declarations or expressions. We also discuss the rules of scope which explain how references to identifiers are resolved. This is somewhat tricky for recursive function declarations.
An environment consist of a static part (giving types to the declared variables) and a dynamic part (giving values to the declared values). At the level of modules, a signature can be thought of as a named static environment, publishing the types associated with variables. A structure is a named dynamic environment containing definitions for the variables in its signature. For now, signatures and structures are used only to refer to the ML Standard Basis Library.