Eiffel Introduction
Eiffel introduction
Rensselaer, 2000
James C. McKim, JR, Rensselaer At Hartford
K] [N g of @ r k translation
[Translator: This article is translated from an outline of the Eiffel, which is very briefly introduced to Eiffel's most best ... basic syntax. Of course, the content of EIFFEL is far more than this. In fact, Eiffel is not just an excellent object-oriented language, more like a set of well-oriented object-oriented development systems, although it is not a mainstream development language, but there is indeed unique exquisite and technical highlights (such as Design by Contract (DBC), an expression method for object-oriented concepts, etc.). In particular, DBC is attached to the mainstream area. C Assertion, Assert and IContract in Java can be considered as DBC embodiments. ]
[Translation: The terminology in this translation is preferred to use the original text. Some terms are translatics to consider the results of their own, not necessarily completely accurate or proper. Welcome to the criticism. ]
1. Why use Eiffel?
1.1 Why use Eiffel?
l Eiffel is a very simple language. Similar to Pascal, but the keyword is less than pASCAL, read as a false code.
l We are trying / need an object-oriented language. Booch said: "Eiffel is the best object-oriented language on the market. (Eiffel Is The Best Designed Oo Language on The Market.)"
l Allow compilation and testing of the class (modules) or module) in a direct and reasonable manner.
l Eiffel is a pure object-oriented language to support object-oriented concepts in a very straightforward manner.
l Compared with any other commercial language, Eiffel has more object-oriented characteristics. For example, static type, multiple inheritance, genericity, assertion (ASSERTION).
l In short, if you want to learn about object-oriented knowledge, Eiffel is the best learning tool!
1.2 Why don't you use Eiffel?
l Eiffel has not been widely used in commercial applications.
l For most implementations, the compilation speed is slow.
2. Eiffel's grammar and control structure
2.1 Eiffel control structure
2.1.1 Eiffel has only one loop structure
From
.... - Set the initial condition here
.... - You can write any more
Until
Condition
loop
.... - Here is a cyclic body
.... - You can write any more
end
2.1.2 Cyclic Structure Example
Sum: = 0
From
i: = 1
Until
i> 10
loop
Sum: = SUM I
i: = i 1
end
Please note that in this case, you must manually increment cycle variables. You may sometimes forget this.
2.1.3 Branch structure
IF cond1 then
...
...
Elseif Cond2 Then
...
...
Else ...
...
end
There can be any plural of Elseif, or nothing can be made. The ELSE clause is also optional. But must have an end statement end.
2.1.4 multi-branch structure
Inspect expression
When const1 then
...
...
When const2 then
...
...
Else
...
...
end
2.1.5 Example of multi-branch structure
Inspect ch
When 'a' .. 'Z', 'a' .. 'Z' Then
- Handling letters
When '0' .. '9' Then
- Processing numbers
When '.'
- The situation ends with '.'
Else
- Default action
end
(to be continued)