Translation to Romanian,
by Alexandra Seremina,
Translation to French,
by Vicky Rotarova.
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
The main language constructs added are signatures and signature pointers.
For example, the signature declaration
defines a new abstract type
int foo (void);
int bar (int);
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,
defines a signature pointer
S * p = &obj;
p and initializes it to point to
an object of class type
C is required
to contain the public member functions
int foo (void)
int bar (int). The member function call
int i = p->foo ();
C is called an implementation of the abstract type
S. In this example, we could have made
an abstract virtual class and
C a subclass of
and we would have had the same effect. The advantages of signatures over
abstract virtual classes are
- you can build a type hierarchy separate from the class inheritance
- subtyping becomes decoupled from inheritance (code sharing), and
- signatures can be used with compiled classes, while you cannot
retrofit an abstract virtual class on top of compiled class
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
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 destructor of objects cannot be called though signature pointers.
- Class member functions that are inherited from a virtual base class
are not called correctly through a signature pointer.
- The signature conformance check does not work if the signature
contains other signature declarations or class declarations.
- Operator and conversion operator member functions of signatures
can only be called with function call syntax, such as
p->operator+(17), but not with operator or conversion syntax.
The following language constructs and features are not yet implemented:
The items above are roughly in the order in which they will be implemented.
- constants in signatures,
- signature references,
- signature inheritance,
sigof (signature of a class) construct,
- views (not even the parsing is done),
- signature templates, and
- exception specifications in signature member function declarations.
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
when compiled with G++-2.7.2.