5.2.1. Current context
An automatic action can happen only in a state transition. States are defined with conditions, which are just Boolean queries. The assignments that make up the automatic effect are executed when the condition becomes true. Conceptually, the system observes each context- and role instance. As soon as the state of one of these instances changes in such a way that the condition of one of its defined states evaluates to true, the automatic effect is carried out.
It is therefore important to realise, when reading below about the language for effects, that the effect is computed relative to some context instance. All queries that are part of effect statements are executed with that context instance as their starting point. Below, we call it the current context instance. The current context can actually be used inside an expression. Reflect on the nature of expressions: they trace a path through the network of contexts and roles. Using the keyword currentcontext, the modeller can re-base a subexpression to the context instance that the rule is executed in.
At the same time, the rule is defined in a perspective. The perspective has an object: a role in the context. When the automatic effect is defined on a role state transition, that role is the object. When it is defined on a context state transition, all instances of the role in that context are the object. These instances are bound to the query variable object. It is available in the state condition and in the statements of the effect. It is useful, for example in the situation where one wants to bind that object to a Role instance.