Category:Elena: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 12: Line 12:
ELENA is a general-purpose, object-oriented, polymorphic language with late binding. It features message dispatching/manipulation, dynamic object mutation, a script engine / interpreter and mix-ins.
ELENA is a general-purpose, object-oriented, polymorphic language with late binding. It features message dispatching/manipulation, dynamic object mutation, a script engine / interpreter and mix-ins.


The simplest program
== The simplest program ==
==


To create a simple console program we have to declare the **program** symbol in the project root namespace:
To create a simple console program we have to declare the **program** symbol in the project root namespace:
Line 58: Line 57:
**Console::write** method is similar to **writeLine** except that it writes to the output screen without a new line character.
**Console::write** method is similar to **writeLine** except that it writes to the output screen without a new line character.


Declaring a variable
== Declaring a variable ==
===


A variable can be declared in an assignment statement starting with **var** attribute:
A variable can be declared in an assignment statement starting with **var** attribute:
Line 131: Line 129:
system'startUp(5)
system'startUp(5)
Basic Types
== Basic Types ==
===


The Boolean Type
=== The Boolean Type ===
=====


Boolean type is used in conditional operations and may accept only two Boolean literals - **true** and **false**.
Boolean type is used in conditional operations and may accept only two Boolean literals - **true** and **false**.
Line 161: Line 157:
false==true is false
false==true is false


### The Numeric types
=== The Numeric types ===


The most used numeric types in ELENA are 32-bit signed integer number (represented by **IntNumber**), 64-bit signed integer number (represented by **LongNumber**) and 64-bit floating-point number (represented by **RealNumber**):
The most used numeric types in ELENA are 32-bit signed integer number (represented by **IntNumber**), 64-bit signed integer number (represented by **LongNumber**) and 64-bit floating-point number (represented by **RealNumber**):
Line 184: Line 180:
Real number - 2.3456
Real number - 2.3456


### The string Type
=== The string Type ===


**LiteralValue** is used to store the text encoded in UTF-8. LiteralValus is read-only collection of **CharValue** classes each representing UTF-32 symbol. *Note that one character may be encoded with more than one byte!*.
**LiteralValue** is used to store the text encoded in UTF-8. LiteralValus is read-only collection of **CharValue** classes each representing UTF-32 symbol. *Note that one character may be encoded with more than one byte!*.
Line 263: Line 259:
The last character of Привет is т
The last character of Привет is т


### Array type
=== Array type ===


It is possible to declare a dynamic or static array.
It is possible to declare a dynamic or static array.
Line 286: Line 282:
dynamic array 1,b,2.3
dynamic array 1,b,2.3


## Basic arithmetic operations
== Basic arithmetic operations ==


ELENA supports basic arithmetic operations with integer and floating-point numbers:
ELENA supports basic arithmetic operations with integer and floating-point numbers:
Line 315: Line 311:
12 + 5 * 2.3 = 23.5
12 + 5 * 2.3 = 23.5


## Conditions, Multi-select, Loops
== Conditions, Multi-select, Loops ==


Conditional statement in ELENA are defined as follows:
Conditional statement in ELENA are defined as follows:
Line 390: Line 386:
].
].


## Classes, Fields Methods, Constructors
== Classes, Fields Methods, Constructors ==


Everything in ELENA is a class. So to implement some tasks we will have to declare our own classes.
Everything in ELENA is a class. So to implement some tasks we will have to declare our own classes.


### Declaring a simple class
=== Declaring a simple class ===


Let's create a simple class :
Let's create a simple class :
Line 432: Line 428:
*Note that in ELENA a class is an object itself and can be used by like any other object*
*Note that in ELENA a class is an object itself and can be used by like any other object*


### Class Inheritance
=== Class Inheritance ===


We may inherit our class. When the parent is not explicitly declared - the class inherits *system'Object* super class
We may inherit our class. When the parent is not explicitly declared - the class inherits *system'Object* super class
Line 483: Line 479:
I'm a Child Class.
I'm a Child Class.


### Private methods
=== Private methods ===


It is possible to declare the private methods which cannot be called outside the class.
It is possible to declare the private methods which cannot be called outside the class.
Line 528: Line 524:
system'startUp(5)
system'startUp(5)


### Properties
=== Properties ===


In normal case the class fields cannot be accessed outside the class. That's why we may declare a special method to access it:
In normal case the class fields cannot be accessed outside the class. That's why we may declare a special method to access it:
Line 577: Line 573:
].
].
## Exception Handling
== Exception Handling ==


We may use try-catch statement to handle the possible exceptions:
We may use try-catch statement to handle the possible exceptions: