EIFFEL

Eiffel Types

Type



In Eiffel every entity is declared by either a reference type or an expanded type. It is strongly typed for readability and reliability.

Any type T is based on a class, which defines the operations that will be applicable to instances of T. The difference between the two categories of types affects the semantics of an entity x declared of type T: for a reference type, the most common case, possible values for x are references to objects; for an expanded type, the values are objects. In both cases, the type rules guarantee that the objects will be instances of T.

A non-expanded class such as Account yields a reference type. As a result, an entity of type Account, denotes possible run-time references to objects of type Account.

An important group of expanded types, include the basic types: INTEGER, REAL, DOUBLE, CHARACTER and BOOLEAN. Operations on these types are defined by prefix and infix operators such as "+" and "<".

As a result of these conventions, the type system is uniform and consistent: all types, including the basic types, are defined from classes, either as reference types or as expanded types.

In the case of basic types, for efficiency, the ISE Eiffel compilation mechanism implements the standard arithmetic and boolean operations directly through the corresponding machine operations, not through routine calls. But this is only a compiler optimization, which does not hamper the conceptual homogenity of the typ edifice.