Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81598 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55549 invoked from network); 2 Feb 2015 16:32:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Feb 2015 16:32:08 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.48 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.48 mail-wg0-f48.google.com Received: from [74.125.82.48] ([74.125.82.48:60231] helo=mail-wg0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/14-34915-786AFC45 for ; Mon, 02 Feb 2015 11:32:08 -0500 Received: by mail-wg0-f48.google.com with SMTP id x12so39719063wgg.7 for ; Mon, 02 Feb 2015 08:32: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=dbgYyYW2I1yBfmTKMjJqCofThm4HWZ/iw5F2J7NLlcY=; b=y1rz20itA/DBmhKwJlRth2xhU1MQUuju3yDdVt9mCdfxG8thD8p3m72MfbOjHLSpvF Vu4VDGu8o+kdv0b/zHz89xbsB1tzIc4CWXCcyx5OsU+EAX/1QKWfU9E+ur3JasEEbupm C6ZdRFj1IwDtkfdAbtjqSUUzKmguTto29aVql1zQ4o+P169NBw5t2hO0eGvvhef/mlGn j/8LGV6HMx7mawB2Ms3j/oOg9PwVEWouTC5l0A1MPdajZmWh+P7LlA2ypY25fF3jfjro Ibl8sfLd5MDDLbQ0yvQwMiDofaGHjZZZdFAqG19xhlWdz+0vGuVZHXTxAPxSMnfveXLo pm4w== MIME-Version: 1.0 X-Received: by 10.180.90.177 with SMTP id bx17mr25786328wib.36.1422894724890; Mon, 02 Feb 2015 08:32:04 -0800 (PST) Received: by 10.27.10.138 with HTTP; Mon, 2 Feb 2015 08:32:04 -0800 (PST) In-Reply-To: <1D2674AE-6DA6-42A4-817E-0166F30B667D@ajf.me> References: <1D2674AE-6DA6-42A4-817E-0166F30B667D@ajf.me> Date: Mon, 2 Feb 2015 17:32:04 +0100 Message-ID: To: Andrea Faulds Cc: PHP Internals List Content-Type: multipart/alternative; boundary=f46d043c7dd2a163d0050e1d7e36 Subject: Re: [PHP-DEV] [VOTE] Combined Comparison (Spaceship) Operator From: nikita.ppv@gmail.com (Nikita Popov) --f46d043c7dd2a163d0050e1d7e36 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, Feb 2, 2015 at 4:27 PM, Andrea Faulds wrote: > Hey Nikita, > > > On 2 Feb 2015, at 13:49, Nikita Popov wrote: > > > > I've voted -1 because I think this should be a function and not an > operator. compare($a, $b) is more obvious than $a <=3D> $b and it's not l= ike > writing comparison functions is such a super common use case that it need= s > the extra brevity of an operator. A function can furthermore be used as a > callback, while an operator requires a wrapping closure. > > There=E2=80=99s no actual use for the bare comparison operation as a call= back, > though: usort($foo, =E2=80=98compare=E2=80=99); would just be a slow vers= ion of sort($foo); > It may not be applicable to a direct sort() call, but it's useful for higher level APIs. With a function you can create APIs of the form `function foo(..., $comparator =3D 'compare') { ... }`, which will default = to the "standard" comparison function without having to specially handle it all over the place. Nikita --f46d043c7dd2a163d0050e1d7e36--