Book contents
- Frontmatter
- Contents
- Preface
- Part I Judgments and Rules
- Part II Statics and Dynamics
- Part III Function Types
- Part IV Finite Data Types
- Part V Infinite Data Types
- Part VI Dynamic Types
- Part VII Variable Types
- Part VIII Subtyping
- Part IX Classes and Methods
- Part X Exceptions and Continuations
- 27 Control Stacks
- 28 Exceptions
- 29 Continuations
- Part XI Types and Propositions
- Part XII Symbols
- Part XIII State
- Part XIV Laziness
- Part XV Parallelism
- Part XVI Concurrency
- Part XVII Modularity
- Part XVIII Equational Reasoning
- Part XIX Appendix
- Bibliography
- Index
27 - Control Stacks
from Part X - Exceptions and Continuations
Published online by Cambridge University Press: 05 February 2013
- Frontmatter
- Contents
- Preface
- Part I Judgments and Rules
- Part II Statics and Dynamics
- Part III Function Types
- Part IV Finite Data Types
- Part V Infinite Data Types
- Part VI Dynamic Types
- Part VII Variable Types
- Part VIII Subtyping
- Part IX Classes and Methods
- Part X Exceptions and Continuations
- 27 Control Stacks
- 28 Exceptions
- 29 Continuations
- Part XI Types and Propositions
- Part XII Symbols
- Part XIII State
- Part XIV Laziness
- Part XV Parallelism
- Part XVI Concurrency
- Part XVII Modularity
- Part XVIII Equational Reasoning
- Part XIX Appendix
- Bibliography
- Index
Summary
The technique of structural dynamics is very useful for theoretical purposes, such as proving type safety, but is too high level to be directly usable in an implementation. One reason is that the use of “search rules” requires the traversal and reconstruction of an expression in order to simplify one small part of it. In an implementation we would prefer to use some mechanism to record “where we are” in the expression so that we may resume from that point after a simplification. This can be achieved by introducing an explicit mechanism, called a control stack, that keeps track of the context of an instruction step for just this purpose. By making the control stack explicit, the transition rules avoid the need for any premises—every rule is an axiom. This is the formal expression of the informal idea that no traversals or reconstructions are required to implement it. This chapter introduces an abstract machine K{nat ⇀} for the language ℒ{nat ⇀}. The purpose of this machine is to make control flow explicit by introducing a control stack that maintains a record of the pending subcomputations of a computation. We then prove the equivalence of K{nat ⇀} with the structural dynamics of ℒ{nat ⇀}.
- Type
- Chapter
- Information
- Practical Foundations for Programming Languages , pp. 217 - 223Publisher: Cambridge University PressPrint publication year: 2012