Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81001 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81478 invoked from network); 22 Jan 2015 23:39:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Jan 2015 23:39:49 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.207 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.207 imap2-2.ox.privateemail.com Received: from [192.64.116.207] ([192.64.116.207:59135] helo=imap2-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 92/F3-61273-83A81C45 for ; Thu, 22 Jan 2015 18:39:48 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id EC6058C007D; Thu, 22 Jan 2015 18:39:33 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ZggKcC1ppJ3F; Thu, 22 Jan 2015 18:39:33 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 14DAD8C0009; Thu, 22 Jan 2015 18:39:32 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <54C17E2B.80708@garfieldtech.com> Date: Thu, 22 Jan 2015 23:39:30 +0000 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <73BC4206-BEA9-4416-BBB6-F6F99D9A8623@ajf.me> References: <53F8A1FF-C809-4DDF-9C6F-6916C3E4F044@ajf.me> <3251D635-D97C-4738-B537-935A6CC21E19@ajf.me> <54C17E2B.80708@garfieldtech.com> To: Larry Garfield X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator From: ajf@ajf.me (Andrea Faulds) Hi Larry, > On 22 Jan 2015, at 22:48, Larry Garfield = wrote: >=20 > This looks potentially quite useful, especially for multi-stage = comparisons as you note. Mainly it would mean I don't have to remember = which direction is positive or negative, as I can never get that right = without looking it up. :-) Glad you like it. I, too, sometimes have trouble remembering what = direction it goes in. > The examples say nothing about mixing types, though. Eg, what would = these return: >=20 > return 0 <=3D> "0" >=20 > return "" <=3D> 0 >=20 > return 1 <=3D> [1, 2, 3] >=20 > Ignoring object property names and going by the order of the property = definition seems like asking for trouble, too. >=20 > There may be easy logical answers to the above given PHP's existing = type juggling, but they should be called out explicitly in both the RFC = and in any subsequent documentation. The behaviour would be the same as the current <, <=3D, =3D=3D, >=3D and = > operators. If > currently returns TRUE, then it is 1, if =3D=3D = currently returns TRUE, then it is 0, and if < currently returns TRUE, = then it is -1. Despite all the ridiculousness of our existing comparison = rules, apparently <, =3D=3D and > returning TRUE are mutually exclusive, = thank goodness.=20 I don=E2=80=99t really want to cover this behaviour in the RFC, because = explaining it in full is a considerable effort and the rules it uses are = not new, they are the ones PHP already uses. The behaviour for arrays is = perhaps a little odd, but that is our existing behaviour, and I=E2=80=99d = rather not introduce inconsistency by making <=3D> use different rules = to the other operators. I agree, however, that documentation for this feature should mention the = behaviour, possibly just linking to our existing documentation on type = juggling. Thanks. -- Andrea Faulds http://ajf.me/