Re: equality

Date view Thread view Subject view Author view Attachment view

From: Jos Warmer (
Date: Fri 21 Nov 2003 - 18:15:28 GMT


Integers are datatypes, which do not have identity. The value is the 
identity. Therefore you cannot have
two objects '1'.  Also, collections in OCL are datatypes as well. They 
follow the same rules.

Jos Warmer

At 10:31 AM 11/21/2003 -0500, Tim Klinger wrote:

>Hello all,
>I am a bit confused/concerned about the semantics of equality in 
>OCL2.  The spec (1/6/2003) says (p. 6-3) that an expression like "x = y" 
>evaluates to true if x is the same object as y.  For one thing, this is 
>dependent on the mapping of symbols to objects which is not specified 
>anywhere I've seen.  For example, if I implement the evaluation by 
>creating a new object for each integer literal I encounter then "1 = 1" 
>will be false according to this definition.  Regardless, it doesn't seem 
>natural for the primitive types -- something like "1 = 1.0" will evaluate 
>to false.  The java semantics for primitive types seems more 
>intuitive.  Also, for non-primitive objects, object identity is often not 
>a very useful measure of equality.  Maybe it would be better would be to 
>require the evaluation to use an "equals" method on the types if it one 
>were available and default to object identity if not.  I noticed a 
>proposal in the finalization process to add equality for collection types; 
>object identity will not be very useful in that case either.
>Comments would be welcome.
>Tim Klinger

Klasse Objecten         tel     : +31 (0)35 6037646
Chalonhof 153           fax     : +31 (0)35 6037647
3762 CT Soest           email   :
The Netherlands         internet:

Date view Thread view Subject view Author view Attachment view