Re: OCL equal (=) operator , comparing identities

Date view Thread view Subject view Author view Attachment view

From: Frédéric FONDEMENT (
Date: Thu 24 Jun 2004 - 13:45:23 BST



Here is something I believe since a long time, and I would like somebody to confirm it...

The = operator is nothing but a shorthand for the OclAny::=(OclAny) predefined operation. This means we can compare any kind of object but collections... So


is strictly equivalent to


which is totally legal since both c1 and b2 conform to OclAny ! (unlike the specification states, OCL2.0 final 7.4.5 p.12: "You cannot, for example, compare an Integer with a Boolean or a String.").

This operation is defined as: "True if self is the same object as object2." So it compares objects and not their slots... Obviously, if two objects have not the same type, these are not the same objects and then the result is false...


A question arises then:

which operation is called when I define one of the 

C::=(OclAny) => should override OclAny::=(OclAny)

C::=(B) => should be called rather than OclAny::=(OclAny)

C::=(C) => should not be called assuming B does not conform to C...


Is there somewhere a precise specification explaining how operations are called (including operations defined in diverse paths of a - multiple - inheritance)?


Just a non-connected additional question: does TupleType inherit from OclAny?

Frédéric Fondement

Date view Thread view Subject view Author view Attachment view