Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:102559
Return-Path: <smalyshev@gmail.com>
Mailing-List: contact internals-help@lists.php.net; run by ezmlm
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 84948 invoked from network); 3 Jul 2018 18:51:10 -0000
Received: from unknown (HELO lists.php.net) (127.0.0.1)
  by localhost with SMTP; 3 Jul 2018 18:51:10 -0000
Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass
Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass
Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.54 as permitted sender)
X-PHP-List-Original-Sender: smalyshev@gmail.com
X-Host-Fingerprint: 74.125.83.54 mail-pg0-f54.google.com  
Received: from [74.125.83.54] ([74.125.83.54:41724] helo=mail-pg0-f54.google.com)
	by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP
	id 04/D2-15351-C95CB3B5 for <internals@lists.php.net>; Tue, 03 Jul 2018 14:51:10 -0400
Received: by mail-pg0-f54.google.com with SMTP id l65-v6so1367178pgl.8
        for <internals@lists.php.net>; Tue, 03 Jul 2018 11:51:08 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :content-transfer-encoding;
        bh=h5AjPbwYsL25VrIxiQmWs1nQ9h2DTlFxDBzArSjVlZQ=;
        b=RhiOoCkJ8OXks6/fWQVha2OB7mCmcs3Hjq5XTQTxtLMNsSLvLZrircC0pFeg0tRgsB
         pHwWmAQzQhBTmwrCosDXsc8XBFREGAYWI7fFyr6uyQ0TqgldD93ufxGi1YUGwndlYgyo
         Swl/Drw5ZZQwKLzaW0Pmk0/OleSjpuwQh9AAMLRoW4QWPS6htiApdzjz0DzmwdiAEaA9
         W0v1o5TPYTWkRSgQ9f9pcGwytdjm5sINCOSCKIa2uZCUObBwvdujrxwLQ77EZL02ykmw
         zvKOVdZruJur211iMY+8G1D1ew5wvCBEUxYETiLyNSXjb00mE7QO8HNCCB/NbH9V5ZbC
         oC4A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt
         :message-id:date:user-agent:mime-version:in-reply-to
         :content-language:content-transfer-encoding;
        bh=h5AjPbwYsL25VrIxiQmWs1nQ9h2DTlFxDBzArSjVlZQ=;
        b=DZNDSfPzrO0T7qFlq8YfiDptLtMMiNNXWy6BVeARDHc6tX3GhkB1Xi3BcQhPmoLWoP
         U4r/EEDof1ftX/S0wqZveUZw069UqHgqiG8usgyGpARMgq1mXWA/DpJsDjbcVuWzBNbK
         s1qFBxgyC0A+i0cnBLs+8Y3SdTD+ACx4DGrZTIvPJV9tvg6T75Gzhj0TqddqnrsXQaKS
         PIlIzdo0UwAvNeyUaj/jGiBVHF4opCkeN/wWsllHXXMctHXyalJVVJIXPMYbEhrSkfFa
         FnEqp4JumRQKjAI/N+260HiRaToXj87C6fhnhEBhdyzBvDLn46nT9pQgHvsz6Jp9lc4k
         wU4w==
X-Gm-Message-State: APt69E2CPaVbnEXHvMLDINiaG0IpvCeXxCEzB8IK3i18Xj6ayOidqdYr
	eZ4XQ9ZBzmx2HjrJ/J50tgpQunXiXQ==
X-Google-Smtp-Source: AAOMgpdhj6Ar59HnhQ8ja9HvSNwiA96O9qcc6RVB+fAa95K3d+InfBiPscrNawE4IrfcJrurl0n+Sg==
X-Received: by 2002:a63:4811:: with SMTP id v17-v6mr5385935pga.379.1530643865283;
        Tue, 03 Jul 2018 11:51:05 -0700 (PDT)
Received: from Stas-Pro-2021.local (c-24-4-176-254.hsd1.ca.comcast.net. [24.4.176.254])
        by smtp.gmail.com with ESMTPSA id j23-v6sm3317656pfi.137.2018.07.03.11.51.04
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 03 Jul 2018 11:51:04 -0700 (PDT)
To: Dan Ackroyd <danack@basereality.com>,
 Rudi Theunissen <rtheunissen@php.net>
Cc: PHP internals <internals@lists.php.net>
References: <CAHFNTwccchXDWnpy=rmxRJ+r6rJrr_gs3ojxim+rPQPsKPVvLA@mail.gmail.com>
 <CA+kxMuR7d5GmVxC0v+=+W_TAMLawunsKSCF73cawMbU5jKffQQ@mail.gmail.com>
Openpgp: preference=signencrypt
Autocrypt: addr=smalyshev@gmail.com; prefer-encrypt=mutual; keydata=
 xsJuBE9mqaARCACFSqcGmNunkjQQu3X+yXnTmFeEkvM4JXZTOBdR8aEevNGmmFEfyvjaDjWi
 9hcwp4E/lYtC+P7VsVjM1OSX9eq0jC/lGL0ZyRXek+mNy0n5H1NSuTpf9Y18LMqhc4G+RU+L
 cNiZ9K0DJuOOvNLPxW7OHZguxb3wdKPXNVa2jyRfJAKm2uaJJMT1mTmFT9a0Q8SKr+mUrrJk
 uG0H2o6SzrKt8Wwoint1eh67zVsJaJtQFchnEZnlawIcqP2yC4nLGR3MkubowxoEBYCZet18
 aHVVRbvpG2Qtob8Lu5xrsGbmXymTkHTdpvkfcJFADa8MzOL90zOxXwbGfbIZOlh5En8jAQCX
 lfnx2eQL3BSW/6XANa51dbWiEp1d1BAkpGKtZvlk0Qf+M9WAi+9aXMe3xP5krxtgnRNUf2WN
 6Zdy2MxL1RRJCFbytLhl0ronC49BsGYVGshdEH8xhBbiIOJKuVZ/DTl9bEm7P9c7CC7iJyVC
 khUAhouH6xzZQNLR+RU+QebYzXypVfl99Qk7EdMmr/WAZCHLuvanyqepC5EBsa3VnAfQemSN
 oBeGBKWWLiOsPjvS72+y1z4RUMAfXHn4l/sFMt8zt7/74AmJPwZquV41p4mPO12V4+xPyc6R
 sB84sfsk2QVivU8w8AkvGQeYjXoz7Iwao95+fWteVzZ36KRQvUckP8pGjHlDXnHxJ0HI1I/k
 OBZSjwRwUf0dd73y6erP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P8KQmTl
 1z16gyKbwY3SmyBkwcpOL35nhUWNLy93syPoY6sZUTikr2bZYukHDQ33XBPs4e6MbWKfsa9q
 aVmnlOF3k5UqChjutfHaEa4Q7VP4wBIpphHBi9MI16oJIzzBPbGl2uoedjwiZ6QeQZnSuOVY
 ZxU2d3lRA8PrtfFN1VSlpEm/VcAvtieHUYWHN0wOu+cp3Slr5XJVNjTjJhl28SlinMME54mK
 AGf2Ldr/dRwXwmEEGBEIAAkFAk9mqaACGwwACgkQL3lWvF2gS126EQD/VVd3FgjLKglClRQP
 zdfU847tqDK4zJjbmRv5vLLwoE0A+wbrQs7jVGU3NrS0AIl5vUmewpp2BKzSkepy23nWmejw
Message-ID: <400c6be3-c4b4-192b-d76e-2dc70cdaf30f@gmail.com>
Date: Tue, 3 Jul 2018 11:51:03 -0700
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0)
 Gecko/20100101 Thunderbird/60.0
MIME-Version: 1.0
In-Reply-To: <CA+kxMuR7d5GmVxC0v+=+W_TAMLawunsKSCF73cawMbU5jKffQQ@mail.gmail.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Subject: Re: [PHP-DEV] Equality and relative ordering of objects
From: smalyshev@gmail.com (Stanislav Malyshev)

Hi!

> I think if you want to push the RFC forward, a really quite strong
> case needs to be made for why having it be a language level feature is
> so much better (or even at all better) than having it be implemented
> in userland.

I tend to agree here. There are not that many cases where < and > are
natural for objects - mostly for implementation of extended numeric
types like complex numbers, but that's not a very common thing people do
in PHP. And when they do, they usually come with custom methods, since
these types work different from scalar types.

Sorting may be a major use case, but there I think using custom sort
functions have it covered. So I'd like to see more specifically on the
case why it's important to have operators and not specialized methods
for objects in the RFC. Especially for </> kind - I can see some case
for non-strict equality, but ordering seems to be a bit exotic (I may be
missing some cases though).

There are also some complications there. I.e., if you implement both
__compare and __equals, you essentially have two functions that do
"equals" - you probably won't want to call both for something like >=?
But that creates an opening for very weird bugs.

Also note: Python had __cmp__ in Python 2, but they moved away from it
to specialized comparison methods in Python 3. It would be a good idea
to look into why they did it, so we could learn from their experience.
Doesn't mean our decision would be the same, but it looks like they had
something that made them change it, so I think we should at least
consider what it was.
-- 
Stas Malyshev
smalyshev@gmail.com