Book contents
- Frontmatter
- Contents
- Preface
- 1 Predicate Logic
- 2 The Simple Imperative Language
- 3 Program Specifications and Their Proofs
- 4 Arrays
- 5 Failure, Input-Output, and Continuations
- 6 Transition Semantics
- 7 Nondeterminism and Guarded Commands
- 8 Shared-Variable Concurrency
- 9 Communicating Sequential Processes
- 10 The Lambda Calculus
- 11 An Eager Functional Language
- 12 Continuations in a Functional Language
- 13 Iswim-like Languages
- 14 A Normal-Order Language
- 15 The Simple Type System
- 16 Subtypes and Intersection Types
- 17 Polymorphism
- 18 Module Specification
- 19 Algol-like Languages
- Appendix: Mathematical Background
- Bibliography
- Index
2 - The Simple Imperative Language
Published online by Cambridge University Press: 28 January 2010
- Frontmatter
- Contents
- Preface
- 1 Predicate Logic
- 2 The Simple Imperative Language
- 3 Program Specifications and Their Proofs
- 4 Arrays
- 5 Failure, Input-Output, and Continuations
- 6 Transition Semantics
- 7 Nondeterminism and Guarded Commands
- 8 Shared-Variable Concurrency
- 9 Communicating Sequential Processes
- 10 The Lambda Calculus
- 11 An Eager Functional Language
- 12 Continuations in a Functional Language
- 13 Iswim-like Languages
- 14 A Normal-Order Language
- 15 The Simple Type System
- 16 Subtypes and Intersection Types
- 17 Polymorphism
- 18 Module Specification
- 19 Algol-like Languages
- Appendix: Mathematical Background
- Bibliography
- Index
Summary
Most serious programming languages combine imperative aspects, which describe computation in terms of state-transformation operations such as assignment, and functional or applicative aspects, which describe computation in terms of the definition and application of functions or procedures. To gain a solid understanding, however, it is best to begin by considering each of these aspects in isolation, and to postpone the complications that arise from their interactions.
Thus, beginning in this chapter and continuing through Chapter 7 (nondeterminism) and Chapters 8 and 9 (concurrency), we will limit ourselves to purely imperative languages. Then, beginning in Chapter 10, we will turn to purely functional languages. Languages that combine imperative and functional aspects will be considered in Chapter 13 (Iswim-like languages) and Chapter 19 (Algol-like languages).
In this chapter, we consider a simple imperative language that is built out of assignment commands, sequential composition, conditionals (i.e. if commands), while commands, and (in Section 2.5) variable declarations. We will use this language to illustrate the basic concept of a domain, to demonstrate the properties of binding in imperative languages, and, in the next chapter, to explore formalisms for specifying and proving imperative program behavior. In later chapters we will explore extensions to this language and other approaches to describing its semantics.
At an intuitive level, the simple imperative language is so much a part of every programmer's background that it will hold few surprises for typical readers. As in Chapter 1, we have chosen for clarity's sake to introduce novel concepts such as domains in a familiar context. More surprising languages will come after we have sharpened our tools for specifying them.
- Type
- Chapter
- Information
- Theories of Programming Languages , pp. 24 - 53Publisher: Cambridge University PressPrint publication year: 1998