Issue 19621: allInstances() needs clarification (qvt-rtf) Source: Model Driven Solutions (Dr. Edward Willink, ed(at)willink.me.uk) Nature: Clarification Severity: Minor Summary: OCL's allInstances() applies to the one and only immutable model extent. The meaning of this in QVT with multiple, some mutable, extents/domains/typedModels is unclear. Suggest that allInstances applies to all the input and original inout extents only. Obtaining instances from other domains is available through alternate library operations such as objectsOfType in QVTo. Resolution: allInstances() needs clarification OCL's allInstances() applies to the one and only immutable model extent. The meaning of this in QVT with multiple, some mutable, extents/domains/typedModels is unclear. Suggest that allInstances applies to all the input and original inout extents only. Obtaining instances from other domains is available through alternate library operations such as objectsOfType in QVTo. Discussion - QVTo allInstances() could be defined to apply to the initial, prevailing or final state. Since a QVTo execution proceeds through a predictable sequence of states limiting allInstances() to the initial state is unhelpful. A limitation to the final state is almost unuseable and may require a tool to introduce another form of late processing. Therefore the prevailing state is most appropriate for a QVTo allInstances().The returned instances are the mutable instances since any form of caching would impose an unjustified overhead. Discussion - QVTr/QVTc allInstances() could be defined to apply to the initial, prevailing or final state. The initial state is easy. The prevailing state does not exist declaratively. The final state is harder but may be useful for computing derived output values based on the outputs. However consider a cascade of endogeneous transformations A2B, B2C, C2D in which B2C performs an allInstances(). If we now compose the trio into A2B2C2D, the functionality of the allInstances() must not change. Therefore neither initial nor final state will do, since the initial state changes from B to A and the final state from C to D. We must use a prevailing state, which we can define as the final state of the domain in which the invocation of allInstances() occurs. For our example this is one of B or C and does not change as a consequence of the cascade. Revised Text: Add a new sub-clause 6.5 OCL usage in QVT The QVT languages introduce controlled mechanisms for object mutation that conflict with OCL's expectations of stability. These conflicts are clarified in this subclause. . Essential OCL is used as the expressions language for QVT Relations, Core and Operational Mappings. It is a side effect free language that supports evaluation of constraints on the unchanging state of the objects in a model. (<footnote> Operation pre- and post-conditions and @pre extend this to two states.) 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. allInstances() is therefore defined to return the final state of instances in the domain within which allInstances() is invoked. Imperative OCL is an extension of Essential OCL with additional facilities to realize the side effects required by QVT Operational Mappings. 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. Before "8.3.18 predefined tags" add 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. For QVTo, the prevailing state is used; successive calls to allInstances() may return different sets of mutable instances. Instances are returned from all the 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. Actions taken: September 25, 2014: received issue December 22, 2015: Resolved March 29, 2016: closed issue Discussion: End of Annotations:===== m: webmaster@omg.org Date: 25 Sep 2014 10:12:55 -0400 To: Subject: Issue/Bug Report ******************************************************************************* Name: Ed Willink Employer: mailFrom: ed@willink.me.uk Terms_Agreement: I agree Specification: QVT Section: all FormalNumber: QVT 1.2 Version: all Doc_Year: Year Doc_Month: Month Doc_Day: Day Page: all Title: allInstances() needs clarification Nature: Clarification Severity: Minor CODE: 3TMw8 B1: Report Issue Remote Name: edwillink.plus.com Remote User: HTTP User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0 Time: 10:12 AM Description: OCL's allInstances() applies to the one and only immutable model extent. The meaning of this in QVT with multiple, some mutable, extents/domains/typedModels is unclear. Suggest that allInstances applies to all the input and original inout extents only. Obtaining instances from other domains is available through alternate library operations such as objectsOfType in QVTo.