Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83296 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 85792 invoked from network); 20 Feb 2015 13:20:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2015 13:20:53 -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.179 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.179 mail-we0-f179.google.com Received: from [74.125.82.179] ([74.125.82.179:33973] helo=mail-we0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 83/C4-54878-3B437E45 for ; Fri, 20 Feb 2015 08:20:52 -0500 Received: by wesq59 with SMTP id q59so5630849wes.1 for ; Fri, 20 Feb 2015 05:20:48 -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=zrORWYFKB+DwX0tYO6UXCvBzdC+W5wJUbqyN2D/X63U=; b=usjF+aYoFCao3yZPsZG//dDarOk04M7AwF7lJdT0CBuASdEUmn6kzhiiMNt1h7trnB VJgpS/4o9hWQJb3J9A1ZNJ2JIDAFFy7AA3OZiypLBMOC5IJ5IXug+Ru8iXMW4f3a5DIy E61C6WkwTfbDlwIUduHchHWm8v0Joch8b5pxK5yaoAUE/ASMQdctsFzvtf9wwOKMYXfm wYA9XCm8Ra5k8Sja6cw8mUyHu4uXDTf0nGluBpq4a1FVVdpcVL/fYV7SWI+J+tP5Gy/I v8WBYO+LH6FVP29nBXU8WyJjofvOVYzB2a2lOsnreyPWdRY3zQyprqZLc8T2Te7+lI/g BLgQ== MIME-Version: 1.0 X-Received: by 10.194.71.175 with SMTP id w15mr18538744wju.16.1424438448580; Fri, 20 Feb 2015 05:20:48 -0800 (PST) Received: by 10.27.10.168 with HTTP; Fri, 20 Feb 2015 05:20:48 -0800 (PST) In-Reply-To: References: Date: Fri, 20 Feb 2015 14:20:48 +0100 Message-ID: To: Adam Harvey Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bfcf000bb6c27050f84eb50 Subject: Re: [PHP-DEV] [RFC] Comparable: the revenge From: nikita.ppv@gmail.com (Nikita Popov) --047d7bfcf000bb6c27050f84eb50 Content-Type: text/plain; charset=UTF-8 On Thu, Feb 19, 2015 at 10:40 PM, Adam Harvey wrote: > Hi all, > > Those of you with long memories will remember that I proposed a > Comparable interface way back in the pre-5.4 days, but withdrew it > when it became obvious that there was no consensus for it as a feature > and that a vote was likely to fail. > > RFC: https://wiki.php.net/rfc/comparable > PR: https://github.com/php/php-src/pull/1097 > > Why reanimate it now, I hear you ask? I think that comparisons have > only become more prominent in the language: we now have a spaceship > operator for explicit comparisons, yet the behaviour of object > comparisons can be obscure, to say the least, and the user has no > control over how their objects are compared. > > At this stage, I intend to put this up for a vote on March 5 (vote > ending March 12), with the obvious endgame being that this would be > included in 7.0. > Some technical notes on the RFC text: * "How it is ensured that if $a < $b then $b > $a?" The RFC claims that it is up to the developer to ensure this, however I don't think this is true. As far as I know PHP will implicitly enforce this. It would be good if you could double-check the behavior. * "If both $a and $b are objects with different compare functions, how it is determined whose function is used" Here you answer that the left operand wins. Once again I am unsure whether this is true - I'd assume that for > and >= the right operand wins. * I would appreciate a note that indicates how non-total / non-trichotomous comparisons can be implemented, namely by returning 1 irregardless of order. You can use a subset-relationship to illustrate this. * Have you considered the impact on exception-safety this may have? Did you verify that all places where compare_function (or derivatives) are used are exception-safe? Nikita --047d7bfcf000bb6c27050f84eb50--