Issue 14851: OCL 2.1 Nested Collection Iteration (ocl2-rtf) Source: Model Driven Solutions (Dr. Edward Willink, ed(at)willink.me.uk) Nature: Uncategorized Issue Severity: Summary: The OCL specification does not make clear whether an iteration over a Collection of Collections should operate on the flattened or unflattened source. The Appendix through lack of specification and explicit specification of flattening would suggest that the iterator for a Collection of Collections is a Collection. Most of the description in Section 7.6 is neutral through use of the term element. However In 7.6.1 "The variable v is called the iterator. When the select is evaluated, v iterates over the collection and the boolean expression-with-v is evaluated for each v. The v is a reference to the object from the collection and can be used to refer to the objects themselves from the collection." implies that the source collection is flattened; at least in OCL 2.0 where collections were not first class objects, this is a contradiction. In OCL 2.1, collections are nearly first class objects and so perhaps there is just an ambiguity. Similarly: In 7.6.2 "When we want to specify a collection which is derived from some other collection, but which contains different objects from the original collection (i.e., it is not a sub-collection), we can use a collect operation." In 7.6.3 "The forAll operation in OCL allows specifying a Boolean expression, which must hold for all objects in a collection:" In 7.6.4 "The exists operation in OCL allows you to specify a Boolean expression that must hold for at least one object in a collection". Suggest that the specification of iteration avoid the use of 'object', sticking only to 'element'. A clarifying paragraph at the end of 7.6.5 should state that for a 0 or 1 deep Collection source, element is a non-Collection object. For an N-deep Collection source, element is an (N-1)-deep Collection. Resolution: Revised Text: Actions taken: December 10, 2009: received issue Discussion: End of Annotations:===== ronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8GANslIEtUXebi/2dsb2JhbACZB7tZhCwE Date: Thu, 10 Dec 2009 06:34:43 +0000 From: Ed Willink User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) To: issues@omg.org Subject: OCL 2.1 Nested Collection Iteration X-Plusnet-Relay: 7b27d1e708d64f3b602a381f550960d4 Hi The OCL specification does not make clear whether an iteration over a Collection of Collections should operate on the flattened or unflattened source. The Appendix through lack of specification and explicit specification of flattening would suggest that the iterator for a Collection of Collections is a Collection. Most of the description in Section 7.6 is neutral through use of the term element. However In 7.6.1 "The variable v is called the iterator. When the select is evaluated, v iterates over the collection and the boolean expression-with-v is evaluated for each v. The v is a reference to the object from the collection and can be used to refer to the objects themselves from the collection." implies that the source collection is flattened; at least in OCL 2.0 where collections were not first class objects, this is a contradiction. In OCL 2.1, collections are nearly first class objects and so perhaps there is just an ambiguity. Similarly: In 7.6.2 "When we want to specify a collection which is derived from some other collection, but which contains different objects from the original collection (i.e., it is not a sub-collection), we can use a collect operation." In 7.6.3 "The forAll operation in OCL allows specifying a Boolean expression, which must hold for all objects in a collection:" In 7.6.4 "The exists operation in OCL allows you to specify a Boolean expression that must hold for at least one object in a collection". Suggest that the specification of iteration avoid the use of 'object', sticking only to 'element'. A clarifying paragraph at the end of 7.6.5 should state that for a 0 or 1 deep Collection source, element is a non-Collection object. For an N-deep Collection source, element is an (N-1)-deep Collection. Regards Ed Willink