Book contents
- Frontmatter
- Contents
- Preface
- About the illustrations
- List of illustrations
- List of tables
- PART I BACKGROUND
- PART II FIRST EXAMPLES
- PART III LANGUAGE CONSTRUCTS
- 5 Control structures
- 6 Blocks and procedures (1)
- 7 Parameters
- 8 Concurrent communicating processes
- 9 Structured declarations
- 10 Blocks and procedures (2)
- 11 Concurrent object-oriented languages
- 12 Functional programming languages
- PART IV RELATED TOPICS
- Appendix A A big-step semantics of Bip
- Appendix B Implementing semantic definitions in SML
- References
- Index
9 - Structured declarations
Published online by Cambridge University Press: 05 August 2012
- Frontmatter
- Contents
- Preface
- About the illustrations
- List of illustrations
- List of tables
- PART I BACKGROUND
- PART II FIRST EXAMPLES
- PART III LANGUAGE CONSTRUCTS
- 5 Control structures
- 6 Blocks and procedures (1)
- 7 Parameters
- 8 Concurrent communicating processes
- 9 Structured declarations
- 10 Blocks and procedures (2)
- 11 Concurrent object-oriented languages
- 12 Functional programming languages
- PART IV RELATED TOPICS
- Appendix A A big-step semantics of Bip
- Appendix B Implementing semantic definitions in SML
- References
- Index
Summary
In this chapter we give a general treatment of structured declarations. This allows us to give an account of language constructs such as structs in C-like languages and objects in object-oriented languages.
In Section 9.2, we describe a big-step semantics of Bur. Then, in Section 9.3, we consider Coat, a small object-oriented language with classes and dynamically generated objects.
Records
In this chapter, we will use the term record to stand for a structured declaration. We shall allow record declarations inside records. Moreover, records may contain both variables and procedures; this is in contrast to languages such as C and Pascal that allow only the declaration of variables in structured declarations. By allowing procedure declarations as part of a record, we can now view a record as an object. Variables then correspond to the local variables of an object and procedures correspond to object methods. Later, in Section 9.3, we extend this understanding so that we can speak of objects that are dynamically generated instances of classes.
In Figure 9.1 we see an example of a program that has nested record declarations. The program consists of a block which has a record r1 that contains the declaration of a variable x, a procedure p and a record r2. The record r2 contains the declaration of two variables, y and z.
- Type
- Chapter
- Information
- Transitions and TreesAn Introduction to Structural Operational Semantics, pp. 134 - 153Publisher: Cambridge University PressPrint publication year: 2010