Monday, September 20, 2010

ELENA Programming Language: Object model


ELENA is a general-purpose, object-oriented, polymorphic language with late binding. It features multiple dispatching, context-dependent roles, dynamic inheritance and group object support.


The language treats any program as a set of objects (class instances). The program flow is a process of interaction between objects by sending each other messages. A message may have attached information (a message parameter). An object may react on message if it has an appropriate message handler (a method). If the object reacts on the message it is treated as successful otherwise unsuccessful. In its turn the method may send messages to other objects and so on until the flow reaches the method written by external tools (meta method). If the message is unsuccessful the flow is considered to be broken. It's possible to declare alternative flow which are executed if previous ones are broken. The method has only one input parameter and one output parameter (if the method returns itself it may be considered as an input one).
Every object may be formed up with other objects characterizing its internal state. They in turn may be formed with others and so on until meta objects which internal states are considered as raw data.
All referring entities in the language are objects. A variable is a reference to the object allocated in the program heap. The literal and numeric constants are references to the objects allocated in the static memory.


Any object is an instance of one or another class. The classes form the hierarchy tree on the principle of inheritance. There is the common super class - Object. The class parent may be explicitly declared. When the parent is not specified, the class inherits Object.


A class is an abstract concept which means that no operations can be done with it except a declaration. So to create the object its symbol should be referenced. There are explicit and implicit, static and dynamic symbols.
When a new class is declared simultaneously the appropriate implicit symbol is declared as well. The explicit symbol should be declared explicitly. In general the implicit symbol is the object in the initial state and the explicit one is the object in the particular state.
A static symbol is the class instance which state is preserved. A static symbol is always explicit one. There could be only one instance of static symbol.
The class declaration can be named or unnamed (inline declaration) public or private (when the class name is a private name). Its body contains member declarations: fields, roles and methods.


The fields can be accessed only within the class and its descendants. They can be a normal ones (references to another objects) or meta ones (raw data).
The roles are alternative sets of methods which could be used to implement context-dependent object behavior. When it is applied the role overrides the appropriate object methods with its own ones (static mutation).


Methods maybe private or public depending on their name (public or private). All class methods are considered to be polymorphic. It is possible to dispatch the method call depending on its parameter (declarative multi-dispatching). The method has only one input (or nil) and output (or it should return itself) parameters. If the method requires several parameters a special proxy argument list object can be used.


It is possible to declare a special "Any" handler. It is a method which redirects any unhandled message (i.e. messages which are not mapped in the class or its base classes) to the specified target. The target could be a single object (actually mutation) or collection (group object). A group object is a collection of the objects accessible through the common instance reference. The content of the group can be changed dynamically during the object life time (self-modification). The member objects can be a part of different groups or be single. The group can be persistent or temporally created to solve the particular task. The group objects are treated like "normal" ones and no special routines are required to work with them. If two or more members have duplicate methods either the first message mapping is resolved (exclusive mode) or all duplicate methods are executed (broadcast mode) depending on the group type.

No comments:

Post a Comment