Issue 14198: OCL 2.0, 2.1 Loop iterators are not ordered and other inconsistencies (ocl2-rtf) Source: Model Driven Solutions (Dr. Edward Willink, ed(at)willink.me.uk) Nature: Uncategorized Issue Severity: Summary: The iterators of LoopExp and LoopExpEval are not ordered, but the well-formedness constraints on them use ->at() which is only available for ordered collection. Usage of the AST property is subject to a variety of spelling, ordering and multiplicity inconsistencies. Section 7.6.3 and 7.6.4 define extended variants of forAll and exists that have two iterators. Figure 8.2 and Figure 13.3 show an unordered * multiplicity for LoopExp.iterator. The positioning of the VariableExp.referredVariable 0..1 multiplicity makes the diagram easy to mis-read. Section 8.3.1 LoopExp defines iterator as "The iterator variables. These variables are, each in its turn, " implying an ordered collection. Section 8.3.7 LoopExp [2] and [3] use iterator->forAll implying a collection. Section 9.3 IteratorExpCS synthesized attributes use iterators->at(1) and at(2) requiring an ordered collection. Section 9.3 IterateExpCS concrete syntax supports at most one iterator and one accumulator. Section 9.3 IterateExpCS synthesized attributes use iterator.initExpression requiring a non-collection. Figure 10.7 shows LoopExpEval.iterators as unordered 1..n. Section 10.3.1 LoopExpEval defines iterators as "The names of the iterator variables". Section 10.3.7 IterateExpEval [1] uses iterators->at(1) and iterators->at(2) implying an ordered collection with upper bound 2. Section 10.3.7 LoopExpEval [1] has a two way if = 1 else, implying the upper bound is 2. Section 10.3.7 LoopExpEval [3] uses iterators->at(1) and iterators->at(2) implying an ordered collection with upper bound 2. Section 11.9.1 defines the mapping of forAll to iterate for multiple iterators, but IterateExpCS only supports a single iterator. Resolution: Revised Text: In Figure 8.2 and Figure 13.3 change LoopExp.iterator from 0..1 to 1..2 {ordered}. In Figure 8.2 and Figure 13.3 reposition the VariableExp.referredVariable multiplicity to avoid confusion. In Figure 10.7 change LoopExpEval.iterators from 1..n to 1..2 {ordered}. In Section 8.3.1 LoopExp iterator replace The iterator variables by The ordered set of one or two iterator variables. In Section 9.3 IteratorExpCS replace IteratorExpCS.ast.iterators->size() = 1 else IteratorExpCS.ast.iterators->at(2).name = VariableDeclarationCS[2].ast.name and IteratorExpCS.ast.iterators->at(2).type = ... [A] IteratorExpCS.ast.iterators->forAll(initExpression->isEmpty()) ... [C, D] IteratorExpCS.ast.iterator.type = ... body.source.oclAsType (VariableExp).referredVariable = IteratorExpCS.ast.iterator by IteratorExpCS.ast.iterator->size() = 1 else IteratorExpCS.ast.iterator->at(2).name = VariableDeclarationCS[2].ast.name and IteratorExpCS.ast.iterator->at(2).type = ... [A] IteratorExpCS.ast.iterator->forAll(initExpression->isEmpty()) ... [C, D] IteratorExpCS.ast.iterator->at(1).type = ... body.source.oclAsType (VariableExp).referredVariable = IteratorExpCS.ast.iterator->at(1) In Section 9.3 IterateExpCS replace IterateExpCS.ast.iterator.name = if VariableDeclarationCS[1]->isEmpty() then ‘’ ... IterateExpCS.ast.iterator.type = ... IterateExpCS.ast.iterator.initExpression->isEmpty() by IterateExpCS.ast.iterator->at(1).name = if VariableDeclarationCS[1]->isEmpty() then ‘’ ... IterateExpCS.ast.iterator->at(1).type = ... IterateExpCS.ast.iterator->at(1).initExpression->isEmpty() In Section 10.3.1 LoopExpEval iterators replace The names of the iterator variables in the loop expression by The ordered set of names of the one or two iterator variables in the loop expression. Revised Text: Actions taken: August 22, 2009: received issue December 23, 2013: closed issue Discussion: Since multiple iterators in forAll and exists are just syntactic sugar, the Abstract Syntax would be simpler if the sugar was expanded during CST mapping; too late now. Making the iterator collection ordered and consistently 1..2 just narrows the specification to what the well-formedness constraints assume. A syntax change and further work is needed in the IterateExpCS syntax mapping to support multiple iterators. Since forAll is realised by IteratorExpCS, it perhaps doesn't matter that the elaborated concrete syntax in 11.9.1 is a fiction. The text changes below fix everything except this last point. End of Annotations:===== iler: QUALCOMM Windows Eudora Version 7.1.0.9 Date: Mon, 24 Aug 2009 13:45:24 -0400 To: issues@omg.org, ocl2-rtf@omg.org From: Juergen Boldt Subject: issue 14198 -- OCL 2 RTF issue This is issue # 14198 OCL 2.0, 2.1 Loop iterators are not ordered and other inconsistencies The iterators of LoopExp and LoopExpEval are not ordered, but the well-formedness constraints on them use ->at() which is only available for ordered collection. Usage of the AST property is subject to a variety of spelling, ordering and multiplicity inconsistencies. Section 7.6.3 and 7.6.4 define extended variants of forAll and exists that have two iterators. Figure 8.2 and Figure 13.3 show an unordered * multiplicity for LoopExp.iterator. The positioning of the VariableExp.referredVariable 0..1 multiplicity makes the diagram easy to mis-read. Section 8.3.1 LoopExp defines iterator as "The iterator variables. These variables are, each in its turn, " implying an ordered collection. Section 8.3.7 LoopExp [2] and [3] use iterator->forAll implying a collection. Section 9.3 IteratorExpCS synthesized attributes use iterators->at(1) and at(2) requiring an ordered collection. Section 9.3 IterateExpCS concrete syntax supports at most one iterator and one accumulator. Section 9.3 IterateExpCS synthesized attributes use iterator.initExpression requiring a non-collection. Figure 10.7 shows LoopExpEval.iterators as unordered 1..n. Section 10.3.1 LoopExpEval defines iterators as "The names of the iterator variables". Section 10.3.7 IterateExpEval [1] uses iterators->at(1) and iterators->at(2) implying an ordered collection with upper bound 2. Section 10.3.7 LoopExpEval [1] has a two way if = 1 else, implying the upper bound is 2. Section 10.3.7 LoopExpEval [3] uses iterators->at(1) and iterators->at(2) implying an ordered collection with upper bound 2. Section 11.9.1 defines the mapping of forAll to iterate for multiple iterators, but IterateExpCS only supports a single iterator. Juergen Boldt Director, Member Services Object Management Group 140 Kendrick St Building A Suite 300 Needham, MA 02494 USA tel: +1 781 444 0404 x 132 fax: +1 781 444 0320 email: juergen@omg.org www.omg.org