Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:80821 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75198 invoked from network); 19 Jan 2015 14:29:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Jan 2015 14:29:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:37387] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/B5-64889-BB41DB45 for ; Mon, 19 Jan 2015 09:29:15 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 19EB6B00085; Mon, 19 Jan 2015 09:29:12 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id jdhrp5Q9UDJM; Mon, 19 Jan 2015 09:29:12 -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 0BD8CB00087; Mon, 19 Jan 2015 09:29:10 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Mon, 19 Jan 2015 14:29:08 +0000 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <3251D635-D97C-4738-B537-935A6CC21E19@ajf.me> References: <53F8A1FF-C809-4DDF-9C6F-6916C3E4F044@ajf.me> To: Nikita Popov X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Combined Comparison (Spaceship) Operator From: ajf@ajf.me (Andrea Faulds) Hey Nikita, > On 19 Jan 2015, at 14:07, Nikita Popov wrote: >=20 > I like the idea behind this (exposing internal compare_function), but = I don't want to have an extra operator for a minor use case. Please just = introduce a function instead. I originally wanted a function, but an operator has some advantages. = There=E2=80=99s no backwards-compatibility issues from function name = conflicts (nor do we have to break with tradition and use a namespace = despite everything else not having one). The syntax is similar to other = comparisons: we don=E2=80=99t have lt(), gt(), lt_or_eq(), gt_or_eq(), = eq() and not_eq(), we have <, >, <=3D, >=3D, =3D=3D and !=3D. Why, then, = should we have cmp() or compare()? We get to fix one of C=E2=80=99s = mistakes here, in that C (unlike FORTRAN of all things) failed to = provide a three-way comparison operation despite it being useful and = often available natively. <=3D> has a certain brevity and is familiar to = Ruby and Perl users. Plus, it looks cool and has a cool name (not really an argument, I = know). Still, there is a case for a function, but I=E2=80=99m trying for an = operator for now. I quite like how this feature makes multi-item = comparisons much simpler. -- Andrea Faulds http://ajf.me/