Book contents
- Frontmatter
- Contents
- Preface
- Part I Fundamentals of Compilation
- Part II Advanced Topics
- 13 Garbage Collection
- 14 Object-Oriented Languages
- 15 Functional Programming Languages
- 16 Polymorphic Types
- 17 Dataflow Analysis
- 18 Loop Optimizations
- 19 Static Single-Assignment Form
- 20 Pipelining and Scheduling
- 21 The Memory Hierarchy
- Appendix: Tiger Language Reference Manual
- Bibliography
- Index
14 - Object-Oriented Languages
Published online by Cambridge University Press: 05 June 2012
- Frontmatter
- Contents
- Preface
- Part I Fundamentals of Compilation
- Part II Advanced Topics
- 13 Garbage Collection
- 14 Object-Oriented Languages
- 15 Functional Programming Languages
- 16 Polymorphic Types
- 17 Dataflow Analysis
- 18 Loop Optimizations
- 19 Static Single-Assignment Form
- 20 Pipelining and Scheduling
- 21 The Memory Hierarchy
- Appendix: Tiger Language Reference Manual
- Bibliography
- Index
Summary
ob-ject: to feel distaste for something
Webster's DictionaryA useful software-engineering principle is information hiding or encapsulation. A module may provide values of a given type, but the representation of that type is known only to the module. Clients of the module may manipulate the values only through operations provided by the module. In this way, the module can assure that the values always meet consistency requirements of its own choosing.
Object-oriented programming languages are designed to support information hiding. Because the “values” may have internal state that the operations will modify, it makes sense to call them objects. Because a typical “module” manipulates only one type of object, we can eliminate the notion of module and (syntactically) treat the operations as fields of the objects, where they are called methods.
Another important characteristic of object-oriented languages is the notion of extension or inheritance. If some program context (such as the formal parameter of a function or method) expects an object that supports methods m1, m2, m3, then it will also accept an object that supports m1, m2, m3, m4.
CLASSES
To illustrate the techniques of compiling object-oriented languages I will use a simple class-based object-oriented language called Object-Tiger.
- Type
- Chapter
- Information
- Modern Compiler Implementation in ML , pp. 293 - 308Publisher: Cambridge University PressPrint publication year: 1997