OCL 2.5 RTF Avatar
  1. OMG Issue

OCL25 — OCL 2.1 Nested Collection Iteration

  • Key: OCL25-167
  • Legacy Issue Number: 14851
  • Status: open  
  • Source: Model Driven Solutions ( Dr. Edward Willink)
  • 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.

  • Reported: OCL 2.1 — Thu, 10 Dec 2009 05:00 GMT
  • Updated: Thu, 8 Oct 2015 14:12 GMT