C++ Signatures

What are Signatures Anyway?

Roughly, signatures are type abstractions or interfaces of classes. They are related to ML's signatures, categories in Axiom, definition modules in Modula-2, interface modules in Modula-3, and types in POOL-I.

The main language constructs added are signatures and signature pointers. For example, the signature declaration

signature S
{
  int foo (void);
  int bar (int);
};
defines a new abstract type S with member functions int foo (void) and int bar (int). Signature types cannot be instantiated since they don't provide any implementation. Only signature pointers and signature references can be defined. For example,
C obj;
S * p = &obj;
defines a signature pointer p and initializes it to point to an object of class type C, where C is required to contain the public member functions int foo (void) and int bar (int). The member function call
int i = p->foo ();
executes then obj.foo ().

Class C is called an implementation of the abstract type S. In this example, we could have made S an abstract virtual class and C a subclass of S, and we would have had the same effect. The advantages of signatures over abstract virtual classes are

How do I use them?

To experiment with signatures, get a copy of GCC, Version 2.6.0 or higher, preferably Version 2.95. A beta test version of my implementation of signatures is included in the release. All you need to do is to use the g++ command line option
-fhandle-signatures
for compiling C++ code containing signatures.

What's Implemented and What's Not?

Signature declarations and signature pointers are implemented and working. For examples of what's working and how to use them you can have a look at the test files.

The following bugs are known:

The following language constructs and features are not yet implemented:

The items above are roughly in the order in which they will be implemented.

Besides bug fixes, the main features that have been implemented since the last release are default implementations of signature member functions and opaque types. Classes that are defined using multiple inheritance can now be used as implementations of signature types.

For examples of what works and what doesn't, see the test files in the signature testsuite. All test programs are supposed to print "PASS\n" to stdout when compiled with G++-2.7.2.


Gerald Baumgartner