Skip to main content
Version: 7.0

ACTION+ statement

The ACTION+ statement adds an implementation to an abstract action.

Syntax

[ACTION] abstractAction(param1, ..., paramN) +
[WHEN conditionExpr THEN]
{ actionBody }
[OPTIMISTICASYNC]

Description

The ACTION+ statement does not create a new action, but adds another implementation to an already declared abstract action.

For an abstract action of type CASE, the WHEN conditionExpr THEN block is used. For abstract actions of types MULTI and LIST, the implementation is written without the WHEN ... THEN block.

Parameters

  • ACTION

    Optional keyword. Makes it explicit that an action is being extended.

  • abstractAction

    ID of the abstract action being extended.

  • param1, ..., paramN

    List of typed parameters of the implementation being added. It defines its signature. The list may be empty. The number of parameters and their classes must be compatible with the signature of the abstract action. These parameters can be used in actionBody and, for the CASE form, in conditionExpr.

  • conditionExpr

    Expression for the selection condition of this implementation. Used only for an abstract action of type CASE.

  • actionBody

    Body of the added implementation: contents of the {...} operator, i.e. a sequence of action operators and, if necessary, LOCAL declarations. If the abstract action declares a result, the returned value and its parameters must be compatible with that result.

  • OPTIMISTICASYNC

    Keyword that marks the implementation being added as optimistic asynchronous. Used only in forms where one implementation is selected from several.

Examples

CLASS ABSTRACT Animal;
whoAmI ABSTRACT (Animal);

CLASS Dog : Animal;
whoAmI(Dog d) + {
MESSAGE 'I am a dog!';
}

CLASS Cat : Animal;
whoAmI(Cat c) + {
MESSAGE 'I am a cat!';
}
CLASS ABSTRACT Animal;
CLASS Dog : Animal;

notify(Animal a) ABSTRACT (Animal);
notify(Dog d) {
MESSAGE 'Dog';
}

notify[Animal](Dog d) + {
notify(d);
}
CLASS Human;
name = DATA STRING[100] (Human);

testName ABSTRACT CASE (Human);

testName(Human h) + WHEN name(h) == 'John' THEN {
MESSAGE 'I am John';
}
testName(Human h) + WHEN name(h) == 'Bob' THEN {
MESSAGE 'I am Bob';
}
onStarted ABSTRACT LIST ();

onStarted() + {
MESSAGE 'Preparing data';
}
onStarted() + {
MESSAGE 'Starting handlers';
}
edit '{logics.edit}' ABSTRACT MULTI OVERRIDE FIRST (Object) TOOLBAR;

ACTION edit(Object o) + {
SHOW EDIT Object = o DOCKED;
} OPTIMISTICASYNC