6.5 Interpretation of the OCL specification
OCL is a side effect free language that supports evaluation
of constraints on the state of the objects in a model.
(Operation pre- and post-conditions and @pre extend this to
two states.) The controlled mechanisms for object mutation of
the QVT languages conflicts with OCL's expectations of
stability. These conflicts are clarified in this subclause. .
The declarative QVTc and QVTr languages may cascade mappings
in which OCL evaluations access intermediate objects. These
evaluations occur predictably for either an old or a new state
of an object. An old state is inherently stable. The new state
is stabilized by the declarative computation of values before
usage. An exception however arises for allInstances()
for which the declarative mapping execution order is difficult
for a programmer to predict with certainty. This is not
surprising since the uncertain order is a consequence of the
search for matches traversing all relevant instances anyway. allInstances()
is therefore not available for use by declarative
transformations.
The imperative QVTo language performs object mutations as it
advances from one program state to another in a predictable
order. OCL evaluation may be used within each state. The
functionality of allInstances() is clarified in the
Section 8.3.18.
Operations on Classifiers
Classifier::allInstances() : Set(T)
The OCL definition is: The operation allInstances()
returns all instances of the classifier and the classifiers
specializing it. May only be used for classifiers that have
a finite number of instances. This is the case, for example,
for user defined classes because instances need to be
created explicitly, and for enumerations, the standard
Boolean type, and other special types such as OclVoid. This
is not the case, for example, for data types such as
collection types or the standard String, UnlimitedNatural,
Integer, and Real types.
This needs clarification for use in an imperative QVTo
context for which OCL's expectation of an unchanging context
is only valid within sub-expressions of an ImperativeExpression.
The sets of instances returned by successive calls to T::allInstances()
may grow or shrink during the execution of the transformation.
The properties of individual instances may change as a result
of assignments.
Instances are returned from the all model extents for input,
inout and output models. Instances of intermediate objects are
not returned unless they have been added to an extent.
Instances from a metamodel are not returned unless the
metamodel is also an input model. The Model::objectsOfKind()
operation may be used to return selected instances from a
particular model extent.