Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Eiffel (programming language)
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Overall structure=== An Eiffel "system" or "program" is a collection of ''classes''. Above the level of classes, Eiffel defines ''cluster'', which is essentially a group of classes, and possibly of ''subclusters'' (nested clusters). Clusters are not a syntactic [[language construct]], but rather a standard organizational convention. Typically an Eiffel program will be organized with each class in a separate file, and each cluster in a directory containing class files. In this organization, subclusters are subdirectories. For example, under standard organizational and casing conventions, <code>x.e</code> 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. A class also defines its invariants, and contains other properties, such as a "notes" section for documentation and metadata. Eiffel's standard data types, such as <code>INTEGER</code>, <code>STRING</code> and <code>ARRAY</code>, are all themselves classes. Every system must have a class designated as "root", with one of its creation procedures designated as "root procedure". Executing a system consists of creating an instance of the root class and executing its root procedure. Generally, doing so creates new objects, calls new features, and so on. Eiffel has five basic executable instructions: assignment, object creation, routine call, condition, and iteration. Eiffel's control structures are strict in enforcing [[structured programming]]: every block has exactly one entry and exactly one exit. ====Scoping==== 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. To put it in the language of other object-oriented programming languages, all Eiffel attributes are "protected", and "setters" are needed for client objects to modify values. An upshot of this is that "setters" can and normally do, implement the invariants for which Eiffel provides syntax. While Eiffel does not allow direct access to the features of a class by a client of the class, it does allow for the definition of an "assigner command", such as: <syntaxhighlight lang="eiffel"> some_attribute: SOME_TYPE assign set_some_attribute set_some_attribute (v: VALUE_TYPE) -- Set value of some_attribute to `v'. do some_attribute := v end </syntaxhighlight> While a slight bow to the overall developer community to allow something looking like direct access (e.g. thereby breaking the Information Hiding Principle), the practice is dangerous as it hides or obfuscates the reality of a "setter" being used. In practice, it is better to redirect the call to a setter rather than implying a direct access to a feature like <code>some_attribute</code> as in the example code above.{{Citation needed|reason=Working fine in Delphi (Object Pascal) for 25 years. In Eiffel, if a setter is the only way to set an attribute, this must obviously be what is going on. How is that 'obfuscated'?|date=March 2021}} 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. Feature visibility is checked statically at compile-time. For example, (below), the "{NONE}" is similar to "protected" in other languages. Scope applied this way to a "feature set" (e.g. everything below the 'feature' keyword to either the next feature set keyword or the end of the class) can be changed in descendant classes using the "export" keyword. <syntaxhighlight lang="eiffel"> feature {NONE} -- Initialization default_create -- Initialize a new `zero' decimal instance. do make_zero end </syntaxhighlight> Alternatively, the lack of a {x} export declaration implies {ANY} and is similar to the "public" scoping of other languages. <syntaxhighlight lang="eiffel"> feature -- Constants </syntaxhighlight> Finally, scoping can be selectively and precisely controlled to any class in the Eiffel project universe, such as: <syntaxhighlight lang="eiffel"> feature {DECIMAL, DCM_MA_DECIMAL_PARSER, DCM_MA_DECIMAL_HANDLER} -- Access </syntaxhighlight> Here, the compiler will allow only the classes listed between the curly braces to access the features within the feature group (e.g. {{mono|DECIMAL, DCM_MA_DECIMAL_PARSER, DCM_MA_DECIMAL_HANDLER}}). ===="Hello, world!"==== A programming language's look and feel is often conveyed using a [[Hello world program|"Hello, world!"]] program. Such a program written in Eiffel might be: <syntaxhighlight lang="eiffel"> class HELLO_WORLD create make feature make do print ("Hello, world!%N") end end </syntaxhighlight> This program contains the class <code>HELLO_WORLD</code>. The constructor (create routine) for the class, named <code>make</code>, invokes the <code>print</code> system library routine to write a <code>"Hello,</code> <code>world!"</code> message to the output.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Eiffel (programming language)
(section)
Add topic