Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102507 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38524 invoked from network); 27 Jun 2018 22:58:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2018 22:58:43 -0000 Authentication-Results: pb1.pair.com smtp.mail=rudolf.theunissen@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rudolf.theunissen@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.181 as permitted sender) X-PHP-List-Original-Sender: rudolf.theunissen@gmail.com X-Host-Fingerprint: 209.85.217.181 mail-ua0-f181.google.com Received: from [209.85.217.181] ([209.85.217.181:43693] helo=mail-ua0-f181.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 09/A4-01794-3A6143B5 for ; Wed, 27 Jun 2018 18:58:43 -0400 Received: by mail-ua0-f181.google.com with SMTP id z16-v6so2321675uaz.10 for ; Wed, 27 Jun 2018 15:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:from:date:message-id:subject:to; bh=EW4UXW4KNYLiQPsLWj0S6MLfA7GE/EAc9ZRihkmowjM=; b=BDF5y3knt2l93adDY1wBZXAkhrJW1ejhIVGbgEic00opkvADIUB0lAl2eiUeUoJrf0 /W7ewq7mWuKWY3Jh9dnf/yQC3hgWnStDgITUmbpAuH2UYsRxK3WKJX7wvjIOV5Sru0t+ tUBCjkjINzDR3la9Qm5r7FlnICXQNcm7cBpQsFWYKZ/Fze7M8XESdqoKcHtUo8AFiTM2 BqID20qUedoUDAXKMOdLk0LIr9eBSHtp0qSW70oy/0wgd5TrMMU00kAOTgcEWrurTXIo gMeyjBA8XMmhhBnPYwLXaxPvRkicWsGD7SlqjsNG0il74moZhz5dlzdrNM3D117eJaNp Oeww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:from:date:message-id :subject:to; bh=EW4UXW4KNYLiQPsLWj0S6MLfA7GE/EAc9ZRihkmowjM=; b=F0v6LkWhLnoia3bmrNmqjT5Nzq3+nm3Pur6K8bXFMIfJOnMkvfyDpbCGdhMUpwVUkY H+q8dIl1TwuLr3yYrAdHeb3rHg74Grk1kUrYptkXynKHMUkpGz+Rfz1CmyHQ584qPThu RniVIiH/MPKl6levzkPz2hrmdpzjj78ScJ4GiA2laVPSC8d4dvl+kPwUFUpR2sA2Rbnv l8F/kOnR0w8bIPqcCSwia48ec9dcBeanacMdXFlI0/+fy8RjPfuEQBJrxmZHjWuyO2i2 AJgrjaULYb5SeT3KSFsVwECbzWKc9/uwpcIRgXJRynE8E/ytBu/J9IwCa203g+y3Cg8Y ZgeA== X-Gm-Message-State: APt69E2S3GZNMDd6h1+x5QB9GFNHaKR5kcz0xYpGutpv9GaM400RsZDj PSyfVwoUQvAlF86OGt+ZunaKj5B3wXerG4eytoH4thj/ X-Google-Smtp-Source: AAOMgpcBo/uEoFlu3ONNFZAzyxijn07ohpizLcJZJu5DGyR9IHlzs/d/7EkNLUCvd0iYxkVOI7xxkF1dlAjYL2SKjg0= X-Received: by 2002:a9f:35b1:: with SMTP id t46-v6mr4183606uad.190.1530140320364; Wed, 27 Jun 2018 15:58:40 -0700 (PDT) MIME-Version: 1.0 References: Date: Wed, 27 Jun 2018 18:58:29 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000407d3f056fa78e96" Subject: Re: [PHP-DEV] [RFC] User-defined object comparison From: rudolf.theunissen@gmail.com (Rudolf Theunissen) --000000000000407d3f056fa78e96 Content-Type: text/plain; charset="UTF-8" Hi everyone, I've made some changes to the RFC and the implementation today to explain some of the edge cases and combined behaviour better. There are some issues towards the bottom of the RFC that I would really like some opinions on. They all have decisions made but are not concrete, so I'd like to know if anyone has strong opinions on them before they are considered a final part of the RFC. I'm happy with the current state but I'm very open to changing those decisions if there's a good enough reason to. See https://wiki.php.net/rfc/object-comparison#open_issues Thank you On Wed, 27 Jun 2018 at 18:53, Rudolf Theunissen wrote: > In summary, I propose that return type constraints should be removed >> which will allow us to pursue specific operator overloading at a later >> point if we desire > > > There are no return types or parameter types. The only requirement is that > the function is public and not static. > > > On Wed, 27 Jun 2018 at 15:21, Levi Morrison wrote: > >> On Wed, Jun 27, 2018 at 12:24 PM Levi Morrison wrote: >> > >> > On Tue, Jun 26, 2018 at 5:50 PM Rudolf Theunissen >> > wrote: >> > > >> > > Hi everyone, >> > > >> > > This is an RFC that is based on previous discussions here: >> > > https://externals.io/message/102337 >> > > >> > > RFC: https://wiki.php.net/rfc/object-comparison >> > > >> > > The implementation is tested and appears to be working as expected. :) >> > >> > I had some off-list contact with Rudi and generally have agreed with >> > these changes. >> > >> > However, there may be some value in following Python's lead. In Python >> > 2 they had a `__cmp__` magic method and in Python 3 they removed it >> > and added all of these: >> > >> > __lt__ >> > __le__ >> > __eq__ >> > __ne__ >> > __gt__ >> > __ge__ >> > >> > This permits things such as NumPy to overload < to do an element-wise >> > comparison of the members; something like this: >> > >> > np.array([1, 3, 5, 7]) < np.array([2, 1, 6, 6]) >> > // evaluates to np.array([true, false, true, false) >> > >> > If we pursue this Pythonic route then we would also need methods for + >> > - * / % etc. I do not want to derail the conversation too much, but it >> > does seem opportune to discuss operator overloading more generally. >> >> We would still need `__compareTo` if we did operator overloading >> because we have the `<=>` operator. Rudi has pointed out that because >> of this we should be able to overload individual operators at a later >> point without backwards compatibility issues if we so choose. I think >> this is true if we do not constrain the return types. >> >> In summary, I propose that return type constraints should be removed >> which will allow us to pursue specific operator overloading at a later >> point if we desire; an author can always add `: bool` or `: int` to >> their own methods if they so desire. >> > --000000000000407d3f056fa78e96--