Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116797 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47135 invoked from network); 3 Jan 2022 22:58:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jan 2022 22:58:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6EC19180511 for ; Mon, 3 Jan 2022 16:05:32 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com [209.85.222.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 3 Jan 2022 16:05:31 -0800 (PST) Received: by mail-ua1-f46.google.com with SMTP id r15so60419632uao.3 for ; Mon, 03 Jan 2022 16:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4ZDf8pEkciOuCK9vbc2cW0ugpkzys161aBYLVimX7u4=; b=lO+yz7Uw8qyQiC/3MadMczyZGmHIx3XZp3TVaOOlbzDT8dQj+4EZP0VMib8qJFp86y GheavL/Jf8x+2RyFkIvJi+gxZihXlZqS/Kf9BjM9olOmT871RYk4mJQhqkvc4XDsu/sA nF3XJ6tY80+tv/A1yN4/PYb9ojkodc69vS2OXYTpZDOk+NqiXsnam0RQga5HqV/Hx9lF sCoboSf8A0vPI1G5TpDh6wg1zSyROlKUfsHfZ5sC4ad3OwgkUWoQR2l+B9YyaPcvQXhF kV1IjoEIXibbQfTvCKD3aLvpQedRS1kycc1JcSbrLVHJqwcYILlD/5jzURqeFRuONqy8 XOCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4ZDf8pEkciOuCK9vbc2cW0ugpkzys161aBYLVimX7u4=; b=Y7JcTxdY6qaUK3IGX//MLLYY+PQNE9dJ14gGtsT3YxLRc5l2LSi0HSMSDvD6vYMT6Z VEkfx6lEq2l1SYIAm2KlBd4JanvMu02fpuP3aU7iYtHlyh6RvTxuw4pJHCn1NvVVxdps p/8TjoVmNDD+xbItOxSQ+EvOg+5axfBSWk/RSL1MknN2trdrXODLrbhQ74NRMtfbqEwU GE/PLkRu1SEb+WsmzbN0d+yxYS2otsNwKDDuMIoJwufKguJFzP2boyET3vV3QEH0U45s iwBsuxHjbbk1Jrd27F5tM24LbOw83qE0ubuOFkWO7dbCJOjTwRUN70XJAw0mWXGFlAxS 8b2Q== X-Gm-Message-State: AOAM531QIIYUt/n/i0tUyWotS0aF6jYUvNpfAgNEeCnJ2+lL7goM8l5T wJhU1gZ+hbQV0nBsv/tee8lhmdq9h6tOytt0ZIceLg== X-Google-Smtp-Source: ABdhPJx4Um00jdgbef0UNMHs+4nXP4CPL3muJ+V5O6U3ty0pXlNGpyiX++VDz5l+tDMCUl6CNSdESqV1HEyH8Ikdrm0= X-Received: by 2002:ab0:376c:: with SMTP id o12mr1821628uat.2.1641254731119; Mon, 03 Jan 2022 16:05:31 -0800 (PST) MIME-Version: 1.0 References: <3225c921-9b26-d2e0-f76f-45fff6f5a12a@processus.org> <40a1e5fa-396d-d9ef-93ab-6fcfb5054092@processus.org> In-Reply-To: Date: Tue, 4 Jan 2022 01:05:20 +0100 Message-ID: To: Jordan LeDoux Cc: Pierre , Larry Garfield , php internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [VOTE] User Defined Operator Overloads From: andreas@dqxtech.net (Andreas Hennings) On Mon, 3 Jan 2022 at 22:15, Jordan LeDoux wrote: > > On Mon, Jan 3, 2022 at 9:07 AM Pierre wrote: > > > I forgot to answer to that, specifically. I'd much more prefer to have > > an explicit `equals(object $other): bool` (magic or not, really I do not > > care) single method for equality only, that'd be great. In that sense, I > > much preferred specific RFC about `__equalsTo()` or `__compareTo()` > > alone that a huge generic operator overload RFC. I think both could > > actually be separated, it wouldn't be that weird. > > > > Based on the feedback so far, I am... concerned that doing so would leave > the mathematical improvements out in the cold. It seems that a non-trivial > number of voters do not see mathematics as a desirable use case on its own. > > There's not really anything preventing that part from being ripped out on > its own, but the mathematical overloads add almost no complexity on their > own to the patch. One of my main goals in contributing to PHP is to improve > its usability and performance in mathematics. > > Using magic methods instead of the operator syntax would take perhaps 2 > hours to implement, it's a fairly trivial change in the scope of the RFC. > However, I have no plans to bring this back in time for 8.2 should it be > declined with a magic method implementation. Fundamentally, there are many > voters that seem to be more concerned about possible abuse that empirically > does not exist in most languages which have this feature, instead of > improvements to one of the most neglected domains PHP is used in. > > And that's the real crux: *most* (but not all) of the objections raised so > far suggest a future that factually does not exist in the example languages > we can look at which already have this feature. C++ is perhaps the one real > example of widespread abuse, however there are *multiple* aspects of this > RFC which *specifically* target and discourage that kind of abuse. > (Explicit typing of parameters, non-optional support for implied operators, > restrictions on the return types of the == and <=> operators, errors and > exceptions being propagated immediately, etc.) > > Further, the operand is not passed by-reference in this implementation, > which flatly excludes many of the worst possible abuses. > > I understand all of these objections, but I do not agree with them. > Obviously. If I did, then I wouldn't bring this RFC to a vote. What I have > proposed is the most restricted version of operator overloads in any > language I researched, and that is still not enough for many voters, some > of whom have flatly stated that there is no version of this feature they > would ever vote for. If that is the kind of headwind against quite > fundamental improvements to mathematics within the language, then all of my > energy will be required to produce any improvement at all, and I cannot > spend effort on things which are unrelated. To me it is not surprising that an RFC like this would be controversial. We could enter a wonderful new era of value objects with operators, but it is hard to envision that beforehand. The best might be to find and advertise with use cases and examples from other languages. (as mentioned, I don't really know where to start looking, otherwise I would have already shared something) > > Jordan