Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102501 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22190 invoked from network); 27 Jun 2018 18:24:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2018 18:24:29 -0000 Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=levim@php.net; sender-id=unknown Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.41 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 209.85.215.41 mail-lf0-f41.google.com Received: from [209.85.215.41] ([209.85.215.41:41870] helo=mail-lf0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/22-01794-856D33B5 for ; Wed, 27 Jun 2018 14:24:26 -0400 Received: by mail-lf0-f41.google.com with SMTP id y127-v6so2259548lfc.8 for ; Wed, 27 Jun 2018 11:24:24 -0700 (PDT) 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:in-reply-to:from:date :message-id:subject:to:cc; bh=ldk0Sw66Zb4AcA05lQUl5XRNZL9wDdJjyZWho8CYH2w=; b=NaEG47UJM2/I8kfLceT8SWxaRuWchL8lsTyACtpuVTODIb4nH0YZJk0JjvVb2ap0bP PEHP5qyjMCwtZio7/Uqn6joAueHblAiG9N/3crKjzvEKWi8NSB16bMFwz4ZIKu8fC2YK yqf1sAPHpaUAv7U9ulZpinH/aB/f5KM09O1LUWd0Mto8zAKGUNo/cgX8AsShLeLnMAS0 TB7+POMIgO2XTP/+YrX8IvU/oqxlIa5ngPiSC28hpg73t4axUh11yCqOtMkfsGgv+VIC pCAyE8k1rp8z/U8mAUtl1U0zxx1DtToLRVvoXUU/YxMiXaebWCOIFMK2YiwILNXN3xNm 5oqQ== X-Gm-Message-State: APt69E0u3T6CrfXzvBXYYW0bd7bubQ/Zk9h/EaGYWEVKmpEMKZ34bg4/ +FBJBDdJuq/OhCsNbO9A0oOdInD524uuF0WbBYI= X-Google-Smtp-Source: AAOMgpdVDnN5Z1uc/KM+rutkc/v7zN/Wqo3XgTsf0ki0PvQwBZrOUd5cUq35Enww78CTyPKHHHaJek5mThtV5B7bR14= X-Received: by 2002:a19:4a03:: with SMTP id x3-v6mr2445906lfa.136.1530123860953; Wed, 27 Jun 2018 11:24:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 27 Jun 2018 12:24:08 -0600 Message-ID: To: rudolf.theunissen@gmail.com Cc: internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] User-defined object comparison From: levim@php.net (Levi Morrison) 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.