Issue 19019: List and Dict are Classes rather than DataTypes (qvt-rtf) Source: Model Driven Solutions (Dr. Edward Willink, ed(at)willink.me.uk) Nature: Clarification Severity: Significant Summary: Intuitively List and Dict are objects, so if you pass them to a mapping/query/helper as an inout parameter, the object in the caller may be updated by the call. This is the behaviour of a Class Instance not a DataType Value. Please use the open https://bugs.eclipse.org/bugs/show_bug.cgi?id=420150 to discuss this topic. Resolution: List and Dict Class/DataType confusion Intuitively List and Dict are objects, so if you pass them to a mapping/query/helper as an inout parameter, the object in the caller may be updated by the call. This is the behaviour of a Class Instance not a DataType Value. Discussion Equally intuitively List (and Dict) are values. Two distinct 'occurrences' may be equal. This is the behavior of a DataType not a Class. List and Dict are specified as CollectionType (DataType) derivations so we just need to fix up indications that List and Dict are Classes. While clarifying wording, [1]QVT13-120 is merged to remove the prohibition on object creation/update in helpers. ---------------------------------------------------------------------------------------- [1] http://issues.omg.org/browse/QVT13-120 Revised Text: In 8.2.1.15 MappingOperation Executing a mapping operation replace: All out parameters, including result parameters, have their value initialized to null. All in or inout non null values, except for the primitive types are passed by reference. However it is not legal to change the value when an object is declared with in direction kind. by: All Class parameters are passed or returned by reference. An in Class parameter may not be modified. in DataType parameters are passed by value and may be modified by the mapping without affecting the caller. result DataType parameters are returned by value. inout and out DataType parameters are passed by reference-to-variable, that is the caller passes a reference to a variable whose value may be updated zero or more times by the mapping. These updates are visible to the caller. The initial value of each out and result parameter is null. The value of out, inout and result parameters may be updated many times by assignments. The final value of each out, inout and result parameter is returned to the caller. in 8.2.1.12 Helper replace: A helper is an operation that performs a computation on one or more source objects and provides a result. The body of a helper is an ordered list of expressions that is executed in sequence. When more than one result is declared in the signature of the helper operation, the invocation of the operation returns a tuple. Unless the isQuery property is true, a helper may have side-effects on the parameters; for instance, a list may be passed and changed within the body and its effect is visible after the operation call termination. However it is illegal to create or update object instances within a helper operation except for pre-defined types like sets, tuples, and for intermediate properties. by Helpers and queries are operations that perform a computation on one or more source objects and provide a result. The body is an ordered list of expressions that are executed in sequence. A query has no side-effects. The isQuery property is true. All parameters are implicitly in. A helper may have side-effects; for instance, a list may be passed and changed within the body and its effect is visible after the operation call termination. The isQuery property is false. Parameters may be in, inout or out. A helper may create or modify Class instances or mutable DataType values such as List or Dict. A helper or query may create mutable DataType values such as List or Dict or immutable DataType values such as Tuple, Set or String. When more than one result is declared in the signature of a helper operation, the invocation of the operation returns a tuple. All Class parameters are passed or returned by reference. An in Class parameter may not be modified. in DataType parameters are passed by value and may be modified by a helper without affecting the caller. result DataType parameters are returned by value. inout and out DataType parameters are passed by reference-to-variable, that is the caller passes a reference to a variable whose value may be updated zero or more times by the helper. These updates are visible to the caller. The initial value of each out and result parameter is null. The value of out, inout and result parameters may be updated many times by assignments. The final value of each out, inout and result parameter is returned to the caller. Actions taken: October 23, 2013: received issue December 22, 2015: Resolved March 29, 2016: closed issue Discussion: It would be nice to clean this up, but very dangerous to do so without evaluating the consequences for a real implementation and typical transformations. Disposition: Deferred End of Annotations:===== m: webmaster@omg.org Date: 23 Oct 2013 05:52:08 -0400 To: Subject: Issue/Bug Report ******************************************************************************* Name: Edward Willink Employer: mailFrom: ed@willink.me.uk Terms_Agreement: I agree Specification: QVT Section: 8.2.2.25/26 FormalNumber: 11-01-01 Version: 1.1 Doc_Year: Year Doc_Month: Month Doc_Day: Day Page: 121 Title: List and Dict are Classes rather than DataTypes Nature: Clarification Severity: Significant CODE: 3TMw8 B1: Report Issue Remote Name: edwillink.plus.com Remote User: HTTP User Agent: Mozilla/5.0 (Windows NT 6.0; rv:24.0) Gecko/20100101 Firefox/24.0 Time: 05:52 AM Description: Intuitively List and Dict are objects, so if you pass them to a mapping/query/helper as an inout parameter, the object in the caller may be updated by the call. This is the behaviour of a Class Instance not a DataType Value. Please use the open https://bugs.eclipse.org/bugs/show_bug.cgi?id=420150 to discuss this topic.