Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72588 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1268 invoked from network); 14 Feb 2014 10:41:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Feb 2014 10:41:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=ivan.enderlin@hoa-project.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=ivan.enderlin@hoa-project.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain hoa-project.net from 95.130.10.56 cause and error) X-PHP-List-Original-Sender: ivan.enderlin@hoa-project.net X-Host-Fingerprint: 95.130.10.56 host1.ip6-networks.net Received: from [95.130.10.56] ([95.130.10.56:60045] helo=host1.ip6-networks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/13-12906-FC2FDF25 for ; Fri, 14 Feb 2014 05:41:20 -0500 Received: from Hwhost2.local (184-175.106-92.cust.bluewin.ch [92.106.175.184]) by host1.ip6-networks.net (Postfix) with ESMTPSA id 9354160013 for ; Fri, 14 Feb 2014 11:41:16 +0100 (CET) Message-ID: <52FDF2CB.5020308@hoa-project.net> Date: Fri, 14 Feb 2014 11:41:15 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:29.0) Gecko/20100101 Thunderbird/29.0a2 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Combined Comparison Operator From: ivan.enderlin@hoa-project.net ("Ivan Enderlin @ Hoa") On 13/02/2014 04:58, Davey Shafik wrote: > Hey folks, Hello Davey :-), Thanks for the proposal. > I've written up an RFC/Patch to gauge interest and get feedback on the = > addition of a combined comparison (aka: spaceship) operator. > > You can see the RFC at:=20 > https://wiki.php.net/rfc/combined-comparison-operator > > This adds a new operator "(expr) <=3D> (expr)" that returns 0 if both=20 > operands are equal, 1 if the left is greater, and -1 if the right is=20 > greater. > > It works with all types (just as well as <, <=3D, >=3D, > work) and is = > great for usort() callbacks for example. Am I the only one who think that `<=3D>` is already a Mathematical=20 operator standing for the =E2=80=9Cequivalence=E2=80=9D? PHP already uses `=3D>` as a key/value matching operator for pairs in an = array, whereas in Math., it is the =E2=80=9Cimplies=E2=80=9D operator. Ri= ght, we may=20 still introduce the `=3D=3D>` later. But I can't see `<=3D>` becoming `<=3D= =3D>`=20 or even `<=3D=3D=3D>`. Moreover, as Jordi and others have suggested, a simple PHP function will = do the job, and much better. A -1/0/1 result depends on the compared=20 values and the interpretation of these latters: do we compare the number = of pairs in an array, just the keys, just the values, do we also compare = the type=E2=80=A6? To much context for a single unambiguous operator. One= or=20 more dedicated functions (one per type maybe) is a more realistic way in = my opinion. Thoughts? Cheers :-). --=20 Ivan Enderlin Developer of Hoa http://hoa-project.net/ PhD. student at DISC/Femto-ST (Vesontio) and INRIA (Cassis) http://disc.univ-fcomte.fr/ and http://www.inria.fr/ Member of HTML and WebApps Working Group of W3C http://w3.org/