Issue 8937: Notation for accessing class operations is inconsistent (ocl2-rtf) Source: International Business Machines (Dr. Tracy Gardner, tgardner(at)uk.ibm.com) Nature: Uncategorized Issue Severity: Summary: The OCL 2.0 spec is inconsistent on whether class operations, including predefined operations, should be accessed using '.' or '::' notation. E.g. should it be Person.allInstances() or Person::allInstances() The spec uses Person.allInstances() in the text, but the concrete syntax specifies '::'. It seems that most tools have adopted the '.' notation used in the examples which is also backwards compatible with previous versions of OCL. There has also been some adoption of the '::' notation, for example in Warmer and Kleppe's OCL book, see: http://www.klasse.nl/english/boeken/ocl-book-errata.pdf Note: This issue was originally pointed out by Anthony Shuttleworth of Paranor. Proposed solution: The '.' notation is widely used and backwards compatible with previous versions of OCL. It should not be made invalid in OCL 2.0. It may be appropriate to also support the '::' notation if this has been widely adopted. Resolution: Revised Text: Update Section 7.5.10 “Features on Classes Themselves” to provide an example of a static operation on Employee and to clarify that allInstances() is not a static operation: All properties discussed until now in OCL are properties on instances of classes. The types are either predefined in OCL or defined in the class model. In OCL, it is also possible to use static features, applicable to the types/classes themselves rather than to their instances. For example, the Employee class may define a static operation “uniqueID” that computes a unique ID to use in the initialization of the employee ID attribute: context Employee::id : String init: Employee::uniqueID() Static features are invoked using the ‘::’ operator and are distinct from the features of the Classifier metaclass, which include the allInstances operation pre-defined by OCL. If we want to make sure that all instances of Person have unique names, we can write: context Person inv: Person.allInstances()->forAll(p1, p2 | p1 <> p2 implies p1.name <> p2.name) Invocation of allInstances uses the ‘.’ operator rather than ‘::’ because it is not a static operation. It is an operation applicable to instances of the Classifier metaclass, of which Person is an example. Actions taken: July 21, 2005: received issue October 16, 2009: closed issue Discussion: Accessing static features using ‘::’ is unambiguously an invocation of a static property and not a property of the Classifier metaclass. OCL’s TypeExp is, effectively, a Classifier literal expression, so that the ‘.’ operator should invoke features of the Classifier metaclass. An example of this is allInstances(), which is inherited from OclAny (which Classifier implicitly specializes) or allFeatures() (from UML). End of Annotations:===== ubject: OCL 2.0 RTF Issue: Notation for accessing class operations in inconsistent X-Mailer: Lotus Notes Release 6.0.2CF1 June 9, 2003 From: Tracy Gardner Date: Thu, 21 Jul 2005 09:46:33 +0100 X-MIMETrack: Serialize by Router on D06ML067/06/M/IBM(Release 6.53HF247 | January 6, 2005) at 21/07/2005 09:46:33, Serialize complete at 21/07/2005 09:46:33 Issue: Notation for accessing class operations is inconsistent The OCL 2.0 spec is inconsistent on whether class operations, including predefined operations, should be accessed using '.' or '::' notation. E.g. should it be Person.allInstances() or Person::allInstances() The spec uses Person.allInstances() in the text, but the concrete syntax specifies '::'. It seems that most tools have adopted the '.' notation used in the examples which is also backwards compatible with previous versions of OCL. There has also been some adoption of the '::' notation, for example in Warmer and Kleppe's OCL book, see: http://www.klasse.nl/english/boeken/ocl-book-errata.pdf Note: This issue was originally pointed out by Anthony Shuttleworth of Paranor. Proposed solution: The '.' notation is widely used and backwards compatible with previous versions of OCL. It should not be made invalid in OCL 2.0. It may be appropriate to also support the '::' notation if this has been widely adopted. Dr Tracy Gardner MP 154, IBM Hursley, Winchester, SO21 2JN, UK tel:44 (0)1962 817329, internal: 7-247329