Re: Equality and relative ordering of objects

From: Date: Mon, 25 Jun 2018 11:47:32 +0000
Subject: Re: Equality and relative ordering of objects
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to internals+get-102412@lists.php.net to get a copy of this message
> > Java has .equals and .compareTo; these operations are separate. In > Java neither integrates with operators. Yeah that's right. I was just pointing out that Java's == always checks against the reference and you can't override it (so it's like PHP's ===). Their .equals() method is like PHP's ==. I agree that it's better to separate the two operations, which is why the first message in this thread talked about __equals and __compareTo. However, when I started implementing it, I couldn't see a nice way to separate them internally as everything goes through compare_function. On Sun, 24 Jun 2018 at 23:31, Levi Morrison <levim@php.net> wrote: > On Sun, Jun 24, 2018 at 2:31 PM Rudi Theunissen <rtheunissen@php.net> > wrote: > >> > >> Other languages (most? all?) separate equality and ordering for this > reason. > > > > > > Java doesn't really separate them. Their == always > > checks object > reference so is like PHP's ===. > > But they do have the .equals() method on all objects (our ==) and the > collections use that for equality. > > Java has .equals and .compareTo; these operations are separate. In > Java neither integrates with operators. >

« previous php.internals (#102412) next »