Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:72542 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19187 invoked from network); 13 Feb 2014 04:26:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Feb 2014 04:26:38 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.49 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.215.49 mail-la0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:55881] helo=mail-la0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 85/00-18732-C794CF25 for ; Wed, 12 Feb 2014 23:26:37 -0500 Received: by mail-la0-f49.google.com with SMTP id y1so7628909lam.8 for ; Wed, 12 Feb 2014 20:26:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=MquCL+zteMGkCVUkvUQJEcUzQDA3Raq8Q30LN2Uptpc=; b=P/Vb568cePsfmQiY8N+oFYL0tc6QkHObX5PeXBzLfzJ/pCQOROxzAQK4++g3XQ7AoQ SYYPJc617RJtmaGhxt4iScHkha2oc+N2+Oxp0nUt/JlcDVZZ/3L0I9Ku/wK84QVr44lV mGi2Vkmqx88A/Oz3jD85uyOw/cptYeyJQXsqxmLVhrtZXC04ce5WPEs5KcahAIhrHAVJ aPZecOUfd/mMD20LlnNVP3g5UyvR0pTHiX+XdmX5aTXdleCvBn6zPypU0ZASoqtQef3J CKaE+WGsJ+cNgXBAovQYn23hsOthhI5QgUWL3DgI+7E301dlwW3CiKsjeif6dSjq7mfk 3SoA== X-Received: by 10.112.91.228 with SMTP id ch4mr31574950lbb.19.1392265593894; Wed, 12 Feb 2014 20:26:33 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.112.199.37 with HTTP; Wed, 12 Feb 2014 20:25:53 -0800 (PST) In-Reply-To: References: Date: Thu, 13 Feb 2014 13:25:53 +0900 X-Google-Sender-Auth: Va2XodiZZEJ3zKFvuoQpxWF2ELg Message-ID: To: Davey Shafik Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11348aba283e5604f24218c1 Subject: Re: [PHP-DEV] [RFC] Combined Comparison Operator From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11348aba283e5604f24218c1 Content-Type: text/plain; charset=UTF-8 Hi Davey, On Thu, Feb 13, 2014 at 12:58 PM, Davey Shafik wrote: > 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: https://wiki.php.net/rfc/ > combined-comparison-operator > > This adds a new operator "(expr) <=> (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 <, <=, >=, > work) and is great > for usort() callbacks for example. > > Code available here (against 5.6): https://github.com/dshafik/ > php-src/compare/add-spaceship-operator > > I'd love to get this into 5.6, not sure if we hit feature freeze yet. > Also, not sure if it needs 2/3 majority, but assumed so as pow did? > > Thoughts? > > If there is interest, I'll start adding tests. They should be fairly > trivial. > Interesting shortcut operator. I feel closure function is for the task. I would vote 0, but close to -1 since it's only useful for sorting. Is there any other use cases? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11348aba283e5604f24218c1--