Anonymous user
Category:Elena: Difference between revisions
no edit summary
No edit summary |
|||
Line 77:
ELENA does not support multiple inheritance, though it is possible to inherit the code using redirect handler (so called "horizontal inheritance"). When the parent is not provided the class inherits directly system'Object (the super class).
{
#method field2 = theField.▼
}
{
[
theField1 := aField1.
Line 96 ⟶ 95:
]
= MyClass new &Field1:(theField1 + aField1) &Field2:(theField2 + aField2).
}
Line 102 ⟶ 101:
To create a class instance we have to send a message (usually new) to its symbol (a class symbol is declared implicitly for every class and can be used as a normal one)
{
=
}
...
In general the symbol is a named expression and can be used to declare initialized objects, constants, reusable expressions and so on.
A static symbol is the class instance which state is preserved. There could be only one instance of static symbol.
== Code blocks ==
Line 128 ⟶ 127:
ELENA code block consists of a sequence of statements. The block is enclosed in square brackets and may contain nested sub code blocks (which in fact are inline action classes). The statement terminator is a dot.
[
control forrange &int:0 &int:n &do: (&int:i)
Line 151 ⟶ 150:
If the code block contains only return statement the simplified syntax can be used:
or there is an alternative block expression
Line 161 ⟶ 160:
It is possible to declare the block variable and assigns the value to it. The variable name must be unique within the code block scope.
Line 168 ⟶ 167:
ELENA like Smalltalk does not support any special language constructs to implement the conditional branching. Instead special Boolean symbols (system’true and system’false) are used. All conditional operations should return these symbols as a result.
There are three branching methods :
(m == 0)
[
n + 1
]
m + n
].
Line 180 ⟶ 179:
Note that code in square brackets are in fact nested action classes ( an action class is a class supporting evaluate message). So this code is can be written in this form:
(m == 0)
{
eval
Line 187 ⟶ 186:
]
}
eval
[
Line 215 ⟶ 213:
]
! [
]
|