Eiffel (programming language)

Eiffel shuns coding tricks or techniques intended as program optimization hints to a compiler.

The goals are to make the code more readable, and to facilitate concentrating on the important aspects of a program without getting bogged down in implementation details.

Eiffel's simplicity is intended to promote simple, extensible, reusable, and reliable answers to computing problems.

Object-Oriented Software Construction contains a detailed treatment of the concepts and theory of the object technology that led to Eiffel's design.

[9] The design goal behind the Eiffel language, libraries, and programming methods is to enable programmers to create reliable, reusable software modules.

Eiffel supports multiple inheritance, genericity, polymorphism, encapsulation, type-safe conversions, and parameter covariance.

Eiffel's most important contribution to software engineering is design by contract (DbC), in which assertions, preconditions, postconditions, and class invariants are employed to help ensure program correctness without sacrificing efficiency.

Sather, for example, was originally based on Eiffel but has since diverged, and now includes several functional programming features.

The SmartEiffel team has turned away from this standard to create its own version of the language, which they believe to be closer to the original style of Eiffel.

For example, under standard organizational and casing conventions, x.e might be the name of a file that defines a class called X.

A class contains features, which are similar to "routines", "members", "attributes" or "methods" in other object-oriented programming languages.

Eiffel has five basic executable instructions: assignment, object creation, routine call, condition, and iteration.

Unlike many object-oriented languages, but like Smalltalk, Eiffel does not permit any assignment into attributes of objects, except within the features of an object, which is the practical application of the principle of information hiding or data abstraction, requiring formal interfaces for data mutation.

In practice, it is better to redirect the call to a setter rather than implying a direct access to a feature like some_attribute as in the example code above.

[citation needed] Unlike other languages, having notions of "public", "protected", "private" and so on, Eiffel uses an exporting technology to more precisely control the scoping between client and supplier classes.

Thus, within this small block of code, the local variable (e.g. l_attribute) can be statically guaranteed to be non-void (i.e. void safe).

This design choice helps the readability of classes, by avoiding a cause of ambiguity about which routine will be invoked by a call.

Tuples types may be viewed as a simple form of class, providing only attributes and the corresponding "setter" procedure.

A typical tuple type reads and could be used to describe a simple notion of birth record if a class is not needed.

Other programming languages, especially ones that emphasize functional programming, allow a similar pattern using continuations, closures, or generators; Eiffel's agents emphasize the language's object-oriented paradigm, and use a syntax and semantics similar to code blocks in Smalltalk and Ruby.

Prefixing them with agent yields an object that represents the corresponding routine with all its properties, in particular the ability to be called with the appropriate arguments.

To avoid any confusion between the two mechanisms, the design enforces the following principle: For example, NEWSPAPER may conform to PUBLICATION, but INTEGER converts to REAL (and does not inherit from it).

For example, a DATE class may be declared to convert to STRING; this makes it possible to create a string from a date simply through as a shortcut for using an explicit object creation with a conversion procedure: To make the first form possible as a synonym for the second, it suffices to list the creation procedure (constructor) make_from_date in a convert clause at the beginning of the class.

As another example, if there is such a conversion procedure listed from TUPLE [day: INTEGER; month: STRING; year: INTEGER], then one can directly assign a tuple to a date, causing the appropriate conversion, as in Exception handling in Eiffel is based on the principles of design by contract.

[18] Eiffel's view of computation is completely object-oriented in the sense that every operation is relative to an object, the "target".

This makes it possible to design special infix and prefix notations, for example in mathematics and physics applications.

For example, access to an element of a hash table with string keys can be written "Assigner commands" are a companion mechanism designed in the same spirit of allowing well-established, convenient notation reinterpreted in the framework of object-oriented programming.

For example, the hash table class can have the function and the procedure Then to insert an element you have to use an explicit call to the setter command: It is possible to write this equivalently as (in the same way that phone_book ["JILL SMITH"] is a synonym for number := phone_book.item ("JILL SMITH")), provided the declaration of item now starts (replacement for [3]) with This declares put as the assigner command associated with item and, combined with the bracket alias, makes [5] legal and equivalent to [4].

As a result, the structure of an Eiffel class is simple: some class-level clauses (inheritance, invariant) and a succession of feature declarations, all at the same level.

It is possible for example to program machine- and operating-system level operations in C. Eiffel provides a straightforward interface to C routines, including support for "inline C" (writing the body of an Eiffel routine in C, typically for short machine-level operations).