Loop expression
Constraints :
TypeOf(Loop.stopCondition) <: kermeta::standard::Boolean
Returned Type :
In the literature 3 solution are defined for the return value of a loop expression:
Nothing. This is the simplest solution.
The object returned by the expression “body” for the last iteration.
The collection of object returned by the expression “body” for all iterations.
Among these solution, and for the sake of simplicity, we have chosen to implement the first solution in KerMeta.
Expression |
Type |
---|---|
Loop |
result := kermeta::standard::Void |
Block expression
A block is contains a set of statements and a set of rescue block. Each rescue block handles a particular type of exception. The type of an exception can only be a Class.
Constraints :
Block.rescueBlock.exceptionType.type <: kermeta::structure::Class
Block.rescueBlock.exceptionType.upper = 1
Returned Type :
Two alternatives exists in the literature :
Nothing. This is the simplest solution.
The object returned by the last statement of the block.
In KerMeta we have chosen the second solution because it is the choice made in the OCL. If a rescue block is executed, the block expression returns Void.
Expression |
Type |
---|---|
Block |
TypeOf( Block.statement.last ) |
Conditional expression
Constraints :
TypeOf(Conditional.stopCondition) <: kermeta::standard::Boolean
Returned Type :
2 solutions
Nothing. This is the simplest solution.
Support for union types
The first solution 1 has been rejected because it does not allow some very convenient OCL-like expressions.
Expression |
Type |
---|---|
Conditional |
UNION ( TypeOf( Conditional.thenBody ), TypeOf( Conditional.elseBody ) ) |