Re: equality



Date view Thread view Subject view Author view Attachment view

From: Tim Klinger (tklinger@us.ibm.com)
Date: Fri 21 Nov 2003 - 19:12:14 GMT


Jos,

Fair enough.  Although, since it is perfectly possible to have two integer 
objects with the same value in java, it requires a bit of care for the 
implementer.

In any case, what about the other issues?  It doesn't seem useful to 
define equality on non-datatypes as object identity...

Thanks,
Tim





Jos Warmer <J.Warmer@klasse.nl>
Sent by: puml-list-request@cs.york.ac.uk
11/21/2003 01:15 PM
Please respond to puml-list
 
        To:     puml-list@cs.york.ac.uk
        cc:     Puml-List <puml-list@cs.york.ac.uk>
        Subject:        Re: equality


hIM

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. 

Thanks, 
Tim Klinger 

_____________________________________________________
Klasse Objecten         tel     : +31 (0)35 6037646
Chalonhof 153           fax     : +31 (0)35 6037647
3762 CT Soest           email   : J.Warmer@klasse.nl
The Netherlands         internet: http://www.klasse.nl

Date view Thread view Subject view Author view Attachment view