Signatures: A language extension for improving type abstraction and subtype polymorphism in C++

C++ uses inheritance as a substitute for subtype polymorphism. We give examples where this makes the type system too inflexible. We then describe a conservative language extension that allows a programmer to define an abstract type hierarchy independent of any implementation hierarchies, to retroactively abstract over an implementation, and to decouple subtyping from inheritance. This extension gives the user more of the flexibility of dynamic typing while retaining the efficiency and security of static typing. With default implementations and views flexible mechanisms are provided for implementing an abstract type by different concrete class types. We first show how the language extension can be implemented in a preprocessor to a C++ compiler, and then detail and analyse the efficiency of an implementation we directly incorporated in the GNU C++ compiler.

[1]  William R. Cook,et al.  Inheritance is not subtyping , 1989, POPL '90.

[2]  Luca Cardelli,et al.  Subtyping recursive types , 1991, POPL '91.

[3]  Wilf R. LaLonde,et al.  An exemplar based Smalltalk , 1986, OOPLSA '86.

[4]  Robin Milner,et al.  Commentary on standard ML , 1990 .

[5]  David Robson,et al.  Smalltalk-80: The Language and Its Implementation , 1983 .

[6]  Bjarne Stroustrup,et al.  The Annotated C++ Reference Manual , 1990 .

[7]  Bjarne Stroustrup,et al.  Multiple Inheritance for C++ , 1989, Comput. Syst..

[8]  Jacob Katzenelson,et al.  Type matching, type-graphs, and the Schanuel conjecture , 1992, TOPL.

[9]  John Barnes,et al.  Programming in ADA , 1989 .

[10]  David B. MacQueen An implementation of standard ML modules , 1988, LISP and Functional Programming.

[11]  Languages Object-Oriented Programming Systems,et al.  OOPSLA '86 : Object-Oriented Programming Systems, Languages and Applications : conference proceedings, September 29-October 2, 1986, Portland, Oregon , 1986 .

[12]  Richard D. Jenks,et al.  The type inference and coercion facilities in the scratchpad II interpreter , 1987, PLDI 1987.

[13]  Murray Hill An Implementation of Standard ML Modules , 1988 .

[14]  William R. Cook,et al.  Interfaces for strongly-typed object-oriented programming , 1989, OOPSLA 1989.

[15]  David B. MacQueen Modules for standard ML , 1984, LFP '84.

[16]  Luca Cardelli,et al.  Modula-3 language definition , 1992, SIGP.

[17]  Alan Snyder Encapsulation and inheritance in object-oriented programming languages , 1986, OOPSLA 1986.

[18]  Neil Soiffer,et al.  A Smalltalk system for algebraic manipulation , 1986, OOPSLA 1986.

[19]  Vincent F. Russo,et al.  Signature-Based Polymorphism for C++ , 1993, C++ Conference.

[20]  Robin Milner,et al.  Definition of standard ML , 1990 .

[21]  Niklaus Wirth,et al.  Programming in Modula-2 , 1985, Texts and Monographs in Computer Science.

[22]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Inf. Comput..

[23]  Neil Soiffer,et al.  An object-oriented approach to algebra system design , 1986, SYMSAC '86.

[24]  Dave Thomas,et al.  An exemplar based Smalltalk , 1986, OOPSLA 1986.

[25]  Luca Cardelli,et al.  Subtyping recursive types , 1993 .

[26]  Alan J. Demers,et al.  Data types are values , 1985, ACM Trans. Program. Lang. Syst..

[27]  AmericaPierre,et al.  A parallel object-oriented language with inheritance and subtyping , 1990 .

[28]  Languages Object-Oriented Programming Systems,et al.  OOPSLA/ECOOP '90 : addendum to the proceedings : Conference on Object-Oriented Programming: Systems, Languages, and Applications, European Conference on Object-Oriented Programming, Ottawa, Canada, 21-25 October 1990 , 1991 .

[29]  Simon L. Peyton Jones,et al.  Report on the programming language Haskell: a non-strict, purely functional language version 1.2 , 1992, SIGP.

[30]  Richard D. Jenks,et al.  AXIOM: the scientific computation system , 1992 .

[31]  Andrew P. Black,et al.  Object structure in the Emerald system , 1986, OOPLSA '86.

[32]  William R. Cook Interfaces and specifications for the Smalltalk-80 collection classes , 1992, OOPSLA 1992.

[33]  William R. Cook,et al.  Interfaces and specifications for the Smalltalk-80 collection classes , 1992, OOPSLA.

[34]  Gerald Baumgartner,et al.  Implementing signatures for C++ , 1994, TOPL.

[35]  Gerald Baumgartner,et al.  A Proposal to Study Type Systems for Computer Algebra , 1990 .

[36]  Luca Cardelli,et al.  On understanding types, data abstraction, and polymorphism , 1985, CSUR.

[37]  Stephen M. Watt,et al.  The scratchpad II type system domains and subdomains , 1990 .

[38]  Bjarne Stroustrup,et al.  Run Time Type Identification for C++ , 1992, C++ Conference.

[39]  Richard D. Jenks,et al.  The type inference and coercion facilities in the scratchpad II interpreter , 1987, SIGPLAN '87.

[40]  Craig Schaffert,et al.  An introduction to Trellis/Owl , 1986, OOPLSA '86.

[41]  Luca Cardelli,et al.  A Semantics of Multiple Inheritance , 1984, Information and Computation.

[42]  Pierre America,et al.  A parallel object-oriented language with inheritance and subtyping , 1990, OOPSLA/ECOOP '90.

[43]  Neil Soiffer,et al.  A Smalltalk System for Algebraic Manipulation , 1986, OOPSLA.

[44]  Craig Schaffert,et al.  An introduction to Trellis/Owl , 1986, OOPSLA 1986.

[45]  Bjarne Stroustrup,et al.  Parameterized Types for C++ , 1989, C++ Conference.

[46]  William R. Cook,et al.  Interfaces for strongly-typed object-oriented programming , 1989, OOPSLA '89.