Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72559 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6722 invoked from network); 13 Feb 2014 17:14:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2014 17:14:08 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.54 as permitted sender) X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 209.85.216.54 mail-qa0-f54.google.com Received: from [209.85.216.54] ([209.85.216.54:45151] helo=mail-qa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/94-09050-F5DFCF25 for ; Thu, 13 Feb 2014 12:14:07 -0500 Received: by mail-qa0-f54.google.com with SMTP id i13so16650407qae.13 for ; Thu, 13 Feb 2014 09:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=I2YDoNtuSJmY5p6iEDB0OdoeyZzu9yYp+PEzLZz6LHw=; b=SdszKgDBLJt0XhKEQDyrhvDITzUt1sOQU9z3E7HhIK6NR6ny6LwDD6cMdKv0Xyu0Nv RMOZmVWc9V+vcDipuXyXuNyeatBG7bahC/VcHyjMiuV9y4quPvdf+5sFPQpeGwfrskkb mrDp7Hgj8oHsdsz7TIh5ejp8HD4r3gYyCrtfXETRke+Xn0FC6ZlGQfh9H3m+BtlGY0+L 3YquZQkxHfeegMqmTbcsC0uGp3OcQ50kxAkKPs0VjlkLqnneHw6wq8INmxN2BmjqY20k d6mh3HEnIC7UT4zT1147T5X3hlDJEEAp43zrIu7Ctnr1rzCJ54V2CnR2QlUvieRS1OkP mO9A== MIME-Version: 1.0 X-Received: by 10.224.98.212 with SMTP id r20mr4648855qan.0.1392311643981; Thu, 13 Feb 2014 09:14:03 -0800 (PST) Received: by 10.140.18.145 with HTTP; Thu, 13 Feb 2014 09:14:03 -0800 (PST) Received: by 10.140.18.145 with HTTP; Thu, 13 Feb 2014 09:14:03 -0800 (PST) In-Reply-To: <52FCE4FC.6010204@php.net> References: <4ED7146272E04A47B986ED49E771E347BBC71EE997@Ikarus.ameusgmbh.intern> <52FCE4FC.6010204@php.net> Date: Thu, 13 Feb 2014 18:14:03 +0100 Message-ID: To: Davey Shafik Cc: Simon J Welsh , Christian Stoller , internals@lists.php.net Content-Type: multipart/alternative; boundary=089e0149d0d0f4c9bc04f24cd05a Subject: Re: [PHP-DEV] [RFC] Combined Comparison Operator From: pierre.php@gmail.com (Pierre Joye) --089e0149d0d0f4c9bc04f24cd05a Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi David, Thanks for this proposal. On Feb 13, 2014 10:30 PM, "Davey Shafik" wrote: > > On 2/13/14, 2:19 AM, Christian Stoller wrote: >> >> Davey Shafik wrote: >>> >>> This adds a new operator "(expr) <=3D> (expr)" that returns 0 if both >>> operands are equal, 1 if the left is greater, and -1 if the right is >>> greater. >>> >>> It works with all types (just as well as <, <=3D, >=3D, > work) and is = great >>> for usort() callbacks for example. >>> >> >> Why not using `$a - $b` instead of `$a <=3D> $b`? >> >> >> Simon J Welsh wrote: >>> >>> The only real case I see for this is to save some boilerplate when >>> dealing with arrays. Strings have strcmp(), numbers have subtraction >>> And when you=E2=80=99re sorting objects, you probably want to be doing >>> the comparison on some string/numeric property. >>> >> >> Agreed! It would make more sense to write a comparison function for arrays/objects. >> >> >> Best regards >> Christian >> > > This operator DOES work on arrays/objects. The fact it also works on scalar values is a bonus if that's how you want to look at it :P This new operator doea not look too useful to me but here is one comment about objects handling: It compares only values, seems to be the only solution but the actual usage for that is rather inexistent as it compares apples and pears, or am I missing something? Cheers, Pierre --089e0149d0d0f4c9bc04f24cd05a--