Proposed Spec for Eiffel Introspection Library (v0.1.1 - 3/28/99)
Introduction
This page describes a proposed specifications for Eiffel
introspection library. Introspection is also known as
reflection, meta-level programming or
meta-object protocols.
An introspection library allows a running program to examine the
structure of its objects. The minimal number of tasks such a library
must perform is:
- Object manipulations
- Create Eiffel objects given the type name as a string.
- Call a routine on an object given the routine name as
a string.
- Traverse all the attributes of an arbitrary object
and extract or set the values of its attributes.
- Type manipulation
- Given an Eiffel class determine its direct parents.
- Given two Eiffel classes determine if their types
conform.
- Determine if a type of an object conforms to a given class.
The library must be powerful enough to to implement the ELKS
class STORABLE entirely in Eiffel.
Requirements
There are several somewhat arbitrary levels of implementation
that would make this library useful. They are:
- Level 1
Allow manipulation of attributes (setting and reading) and creation
of objects given EIFFEL_TYPE. Ability to disable and enable
assertion checking. Example application: STORABLE.
- Level 2
In addition to level 1 calling of routines is possible. Example
application: Remote Eiffel Invocation, CORBA interface.
- Level3
The ability to examine the state of assertions at runtime.
Example application: debugger (?).
- Level 4
Ability to examine compiled, but not running systems. Example
application: case tools.
Proposed Classes
- EIFFEL_SYSTEM - contains some global
information about the system and acts as a factory class for instances
of EIFFEL_TYPE. It is possible that not all objects in a running Eiffel
system will have an corresponding EIFFEL_TYPE instance to allow
compiler optimizations.
- EIFFEL_TYPE - describes an Eiffel type.
Allows creation of instances of the type and invocation of procedures
and functions. Also allows manpulations of attributes.
- EIFFEL_FEATURE - abstract description
of an Eiffel feature.
- EIFFEL_ROUTINE - description
of a routine, including pre- and postconditions, and argument
types.
- EIFFEL_FUNCTION - description
of a function and its return type.
- EIFFEL_PROCEDURE - description
of a procedure.
- EIFFEL_ATTRIBUTE - description
of an attribute.
- EIFFEL_ASSERTION - description
of an assertion.
- EIFFEL_PARAMETER - description
of a routine parameter.
Inheritance
EIFFEL_TYPE, EIFFEL_SYSTEM and EIFFEL_ASSERTION have no parents or descendants. The
other classes are related as follows:
EIFFEL_FEATURE
EIFFEL_ATTRIBUTE
EIFFEL_ROUTINE
EIFFEL_FUNCTION
EIFFEL_PROCEDURE
Implementation Notes
Today it is possible to implement such library at Level 1 with ISE's
compiler. Level 2 maybe possible with the "delayed calls" features,
but I haven't looked into it.
Changelog
- 3/28/99 - changed EIFFEL_CLASS to EIFFEL_TYPE. Made EIFFEL_TYPE
match TYPE as defined by the ISE Agent paper. Many fixes suggested
by many people.
References
Contributors
These classes and ideas are based on work and discussions with
Jean-Pierre Sarkis, Philippe Stephan, Gurvan Lullien and Nick
Leaton.
The comments of the following people were important in the improvement
of this document: Bertrand Meyer, Eric Bezault, Alexander Kogtenkov,
and Sergei S. Ivanov.
I'm sorry if I left anyone out of this list - I got a lot of emails
following the initial positing.
Richard Bielak
Last modified: Mon Mar 29 11:47:03 EST 1999