topical media & game development
The language Eiffel
The language Eiffel has been designed with
a clear concern for correctness
It supports a bottom-up development approach,
centered around the design of robust classes.
Along with the language,
introduces the notion of contracts
as a means to specify the mutual obligations
between the user of an object and the object
in terms of a client/server
Eiffel -- a language with assertions
- bottom-up development -- class design
- contracts -- specify client/server relationships
Design principles -- correctness
- static typing -- type secure
- multiple inheritance -- polymorphism
- dynamic binding -- refinement
- generic classes -- abstraction
slide: The language Eiffel
Eiffel is a (type secure) statically typed
language, providing multiple inheritance
and generic classes.
Recently, Eiffel-3 has been introduced,
supporting a number of features (such as overloading)
inspired by C++. See [Eiffel3].
The design of Eiffel also reflects a concern with the
software engineering issues involved in the development
and maintenance of class libraries.
The language is built around a number of keywords,
which accounts for an easy to read, albeit somewhat verbose,
layout of programs.
The language Eiffel -- keywords
- class -- a model for a set of objects
- feature -- attribute, function, procedure
- export -- interface declaration
- inherit -- class inclusion and subtyping (!)
- redefine, rename -- to change inherited features
- deferred -- to postpone the implementation
- require, ensure, invariant -- assertions
slide: Eiffel -- terminology
The keyword class precedes a class definition,
according to [Meyer88],
may be considered as a model for a collection of objects.
The keyword feature precedes the attributes, functions
and procedures defined by a class.
The keyword export precedes the list of visible
features, in other words the interface declaration of the class.
The keyword inherit precedes the list of inherited
classes, specifying class inclusion and the subtyping
The keywords rename and redefine
are used to change inherited features.
The keyword deferred may be used to indicate
that a feature will be implemented (in the future) in an inherited
and the keyword obsolete may be used to indicate
that a feature will not be supported in a future release.
Finally, the keywords require, ensure
and invariant indicate assertions that specify
respectively the pre- and post-conditions
for a (method) feature and the class invariant.
Type expressions -- conformance
- basic types -- Boolean, Integer
- formal parameter types -- Array[T], List[T]
- class types -- user-defined
- anchored types -- like current
- arithmetic, comparison, method evaluation --
slide: Eiffel -- type expressions
Eiffel is a strongly typed language.
variables must be explicitly typed by
means of a declaration involving type expressions.
Type expressions range over basic types
(such as Boolean and Integer),
formal type parameters of generic types
(as the T in , which stands for the
type of the elements of the array),
(that are defined by the user)
for instance like current
(which results in the type of the current object,
or self in Smalltalk terminology).
Anchored types present some problems for the type safety
of Eiffel programs. See section
[self-reference] for a discussion.
In [Meyer88] conformance rules are specified
which are used to determine
whether a given type is
a subtype of another type.
[subtypes] for an extensive discussion
of the subtyping relationship.
Value expressions in Eiffel comprise the familiar
arithmetical and comparison operations,
as well as the message expressions of the form
that result in the evaluation of the method m
by the object o.
Parameter passing in Eiffel
Control in Eiffel is meant to be effected primarily
by defining (and redefining) the appropriate classes.
However, control constructs both for branching
and iteration are provided.
Control -- method refinement
- branching -- if ... then ... elsif ... else ... end
- iterations -- from ... until ... loop ... end
slide: Eiffel -- control
The if-statement has a classical form,
as in Pascal.
The iteration-statement may be used in a variety
of ways, as a for-loop and as a while-statement
(by omitting the from) part).
Objects in Eiffel are defined by classes.
A typical class definition is given in slide
The class counter exports the features inc
and val. The feature count is hence private to
an instance of counter, since it does not appear
in the interface defined by the export part.
class counter export inc val feature
count : Integer
create is do count := 0 end
inc( n : Integer ) is
require n > 0 do
count := count + n
ensure count = old count + n
val : Integer is do Result := count end
invariant count >= 0
end -- class counter
slide: Eiffel -- objects
The create feature is automatically exported,
and is used to create an instance of counter by the
statement for a variable x of type counter.
The reserved word Result
is used to return a value from a function
The method feature inc specifies both
a pre-condition and a post-condition.
The reserved word old
is used to access the value
of the instance variable count before evaluating inc.
Finally, the invariance states the constraint
that a counter instance never has a value below zero.
Eiffel supports multiple inheritance.
As an example, look at the class
FixedList in slide
which is implemented as
a combination (by inheritance) of
a generic List and a generic Array.
class Fixed_List[T] export ...
slide: Eiffel -- inheritance
Using (multiple) inheritance implies
that a FixedList may be regarded as
a subtype of both Array and List.
However, the export list in the end determines
what interface is provided
and hence what type the class embodies.
Developing programs in Eiffel is meant to
be primarily a matter of modeling,
that is designing classes and the
(inheritance) relations between classes.
An essential ingredient of class development
is the design of appropriate interfaces.
Rename and/or redefine
class C export ... inherit
A rename m as m1 redefine p
B rename m as m2 redefine q
slide: Eiffel -- techniques
To define a class as (derived from) a combination
of classes, Eiffel allows both the renaming
and redefinition of inherited features.
In [Meyer88], many practical hints are given and
employing these mechanisms.
This section has given an introduction to the Eiffel language.
It discussed the design principles underlying Eiffel,
which may be characterized as being focused
on static typing and support for the development
of reliable programs.
The language Eiffel
- design principles -- correctness
- terminology -- keywords
- syntax -- type conformance, control
- objects -- counter example
- inheritance -- renaming, redefining
slide: Eiffel -- summary
it presented an overview of the keywords related to
the constructs offered,
and discussed type expressions, value expressions
and control statements.
An example was given to illustrate the features offered.
Finally, we looked at the mechanisms of renaming
and redefining, which are needed to
avoid name clashes when using multiple inheritance.
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.