Friday, September 8, 2017
Wednesday, March 29, 2017
Saturday, March 11, 2017
In this tutorial I will show how multi-methods are implemented in ELENA
To take part in parameter dispatching classes should be declared with dispatchable attribute.
To dispatch the parameter we have to send cast message to it:
This approach works quite good for a single parameter. For several parameters this approach works not so good. It is possible to resolve them using several nested closures. Currently general solution is not possible. But basic data types support limited two parameter dispatching:
The result will be:
Friday, March 10, 2017
In this short article I will show how to implement event handler using a new attribute : event
To declare a new event handler we should declare the field with event attribute:
The first parameter indicates the action type (func1 is an action with a single generic parameter), the second one - the property name to be used for attaching the handler.
To attach the handler we have to call the property with our action:
The simple example code is below:
Thursday, February 9, 2017
In this tutorial we will see how to program a simple state machine using Mixins and message dispatching.
Let's just remember that eval message in ELENA can be qualified (e.g. dispatched with a subject).
"subj" is a subject class which qualifies the generic message "eval". In the expression "o~subj" we create a temporal mixin object (so called a temporal mutation). As a result "eval" message is turned into "state0" and is sent to the instance of MyClass.
This principle will help us to create our simple state machine.
The key element is a message dispatching expression:
This code is equivalent to our mutation expression:
As a result we create a state machine without branching operators, using only ELENA dispatching routines.