Obstacl: a Language with Objects, Subtyping, and Classes

Obstacl: a Language with Objects, Subtyping, and Classes

OBSTACL: A LANGUAGE WITH OBJECTS, SUBTYPING, AND CLASSES A DISSERTATION SUBMITTED TO THE DEPARTMENT OF COMPUTER SCIENCE AND THE COMMITTEE ON GRADUATE STUDIES OF STANFORD UNIVERSITY IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF DOCTOR OF PHILOSOPHY By Amit Jayant Patel December 2001 c Copyright 2002 by Amit Jayant Patel All Rights Reserved ii I certify that I have read this dissertation and that in my opin- ion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. John Mitchell (Principal Adviser) I certify that I have read this dissertation and that in my opin- ion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. Kathleen Fisher I certify that I have read this dissertation and that in my opin- ion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. David Dill Approved for the University Committee on Graduate Studies: iii Abstract Widely used object-oriented programming languages such as C++ and Java support soft- ware engineering practices but do not have a clean theoretical foundation. On the other hand, most research languages with well-developed foundations are not designed to support software engineering practices. This thesis bridges the gap by presenting OBSTACL, an object-oriented extension of ML with a sound theoretical basis and features that lend themselves to efficient implementation. OBSTACL supports modular programming techniques with objects, classes, structural subtyping, and a modular object construction system. OBSTACL's parameterized inheritance mechanism can be used to express both single inheritance and most common uses of multiple inheritance. In addition, it can be used to implement designs that are difficult to implement with conventional single or multiple inheritance. There is a large space of possible designs for an object-oriented language. The design of OB- STACL is driven by program design and maintenance needs rather than simplicity or elegance. It explicitly supports both object and non-object forms of abstraction and does not attempt to reduce everything to an object. Although simplicity was not a goal, OBSTACL's objects and classes are simpler than those in many object-oriented languages because many of the prob- lems solved by complicated features in a purely object-oriented language are solved instead by a rich set of non-object features such as modules, first class functions, abstract data types, and parametric polymorphism (generics). In addition several fundamental questions about ab- stractions (identity, deep vs. shallow equality, copying vs. cloning, and mutation) are answered by supporting both objects and non-objects in the same language. The resulting language is straightforward to implement efficiently and relatively simple to analyze mathematically. iv Contents 1 Introduction 1 1.1 Approach . 1 1.2 Scope . 2 1.3 Language design . 4 1.4 Evaluation . 5 1.5 Theory . 6 1.6 Practice . 6 1.7 Summary . 7 2 Concepts 8 2.1 Modules . 9 2.2 Abstract Data Types . 9 2.3 Data Hiding . 10 2.4 Objects . 10 2.5 Substitutivity . 11 2.6 Prototypes . 13 2.7 Classes . 13 2.8 Inheritance . 13 2.9 Types . 15 2.10 Polymorphism . 15 3 Program Design and Maintenance 17 3.1 Modularity and Dependencies . 17 3.2 Abstractions . 19 3.2.1 Abstract Data Types . 19 3.2.2 Objects . 20 3.2.3 Union Types . 21 3.2.4 Multimethods . 22 v 3.2.5 Comparison . 24 3.3 Objects vs. Values . 25 3.4 Polymorphism . 26 3.5 Class Hierarchies . 26 3.6 Design Patterns . 27 3.6.1 Creational . 28 3.6.2 Structural . 29 3.6.3 Behavioral . 30 3.7 Summary . 30 4 Language Space 32 4.1 Using Objects . 32 4.1.1 Selection . 32 4.1.2 Updates . 33 4.1.3 Equality . 35 4.1.4 Object Types . 36 4.1.5 Super Object Type . 38 4.1.6 Access Rights . 39 4.2 Creating Objects . 41 4.2.1 Extensible Objects . 42 4.2.2 Prototypes vs. Classes . 42 4.2.3 Subtyping on Classes . 43 4.2.4 Partial Inheritance . 47 4.2.5 Run Time Inheritance . 48 4.2.6 Multiple Inheritance . 48 4.3 Initializing Objects . 52 4.3.1 Multiple Constructors . 53 4.3.2 Initialization Phases . 53 4.3.3 Order of Construction . 55 4.4 Summary . 56 5 Language Design 57 5.1 Objects . 57 5.1.1 Fields . 58 5.1.2 Methods . 58 5.1.3 Object Types . 59 5.1.4 Substitutivity . 60 5.1.5 Operations . 61 vi 5.2 Classes . 61 5.2.1 Fields . 62 5.2.2 Methods . 63 5.2.3 Inheritance . 63 5.2.4 Constructors . 64 5.2.5 Instantiators . 66 5.2.6 Class types . 68 5.3 Mixins . 70 5.3.1 Definition . 71 5.3.2 Constraints . 72 5.3.3 Application . 74 5.4 Summary . 74 6 Evaluation 75 6.1 Using and defining objects . 75 6.1.1 Equality . 75 6.1.2 Redefinitions . 77 6.2 Object Creation Patterns . 79 6.2.1 Modular Construction . 79 6.2.2 Virtual Constructor . 80 6.2.3 Object Cache . 81 6.2.4 Factory . ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    189 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us