Apama Documentation : Developing Apama Applications : EPL Reference : Types : Reference types : action
action
In addition to defining an action, you can define a variable whose type is action. This lets you assign an action to an action variable of the same action type. An action is of the same type as an action variable if they have the same argument list (the same types in the same order) and return type (if any).
Usage
Defining action type variables is useful for invoking an action and for passing an action to another action.
You can use an action variable anywhere that you can use a sequence or dictionary variable. For example, you can
*Pass an action as a parameter to another action.
*Return an action from execution of an action.
*Store an action in a local variable, global variable, event field, sequence, or dictionary.
You must initialize an action variable before you try to invoke it.
You cannot send, route, emit, or enqueue an event that contains an action type member.
When an action variable is a member of an event the behavior of the action depends on the instance of the event that the action is called on. Consequently, it can be handy to bind an action variable member with a particular event instance. This is referred to as creating a closure. For details, see Using action type variables.
An action variable is a potentially-cyclic type — a type that directly or indirectly refers to itself. For details about the behavior of such objects, see Potentially cyclic types.
When the correlator clones a value that contains an action variable, or copies a value that contains an action variable into a new monitor because of a spawn operation, the correlator preserves the structure inside the value. This means that if two things are references to the same object in the original value, they will be references to the same object in the copy. This includes objects referred to by closures that have been assigned to action variables.
When you call toString() on an object that contains an action variable, the result is the name of the method or action in the action variable. If the action variable contains a closure, the toString() method outputs the bound value followed by the name of the action or method being called on the value. For example:
"E(42).f"
"12.0.rand"
See String form of potentially cyclic types.
When the toString() method encounters an empty action variable the output is new followed by the type. Following are two examples:
*"new action<>"
*"new action<sequence<string>,float> returns boolean"
Methods
The only operation that you can perform on an action variable is to call it. You do this in the normal way by passing a set of parameters in parentheses after an expression that evaluates to the action variable. For an example and additional details, see Using action type variables.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback