Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115774 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70794 invoked from network); 23 Aug 2021 13:29:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Aug 2021 13:29:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8068D1804CF for ; Mon, 23 Aug 2021 07:03:13 -0700 (PDT) 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.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS16276 94.23.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from processus.org (ns366368.ip-94-23-14.eu [94.23.14.201]) (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, 23 Aug 2021 07:03:12 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by processus.org (Postfix) with ESMTPA id 8A0E15101324; Mon, 23 Aug 2021 14:03:06 +0000 (UTC) To: Jordan LeDoux , PHP internals References: <2fd2d665-ca3a-4fa8-9196-6c8b1b2a3da0@www.fastmail.com> Message-ID: <2beca228-39ab-a2c6-41c2-136d88551205@processus.org> Date: Mon, 23 Aug 2021 16:03:05 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: processus.org; auth=pass smtp.auth=pierre-php@processus.org smtp.mailfrom=pierre-php@processus.org X-Spamd-Bar: / Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads From: pierre-php@processus.org (Pierre) Le 23/08/2021 à 15:37, Jordan LeDoux a écrit : > Pierre and Dik, > > The thread you were replying to is older and doesn't reference the current > RFC: https://wiki.php.net/rfc/user_defined_operator_overloads > > This is the current discussion thread for the RFC. > > In particular, I'd encourage reading about which operators are supported, > the restrictions on the implementations, and the failure mode behavior. > > Pierre: >> and hell, if "->" doesn't mean "access that object member" anymore, but > "hey, the implementor could do anything at all instead", sky will fall upon > us. > > I hate to break it to you, but __call and __get already do this, and aren't > even a part of this RFC. I'd highly encourage you to read what operators > are supported and how, because this RFC definitely does not suggest opening > ALL operators to overloads. There are very deliberate omissions. Yes, I'm well aware of that, but better stick with the devil you know :) Anyway, I always thought that __set, __get __call and __invoke should have been banned a long time ago. I the hell the paved with good intentions and we cannot remove those since it would be a too big BC break. At least, we know those quite well and are used to it, but do it with *all* operators and code reading will become a real mess (you have to mentally switch from reading the line with an operator to grep some code in order to find the operator overload definition, whereas a nice method call makes everything clear and navigable in any IDE). I read the whole RFC, I'm still not convinced it's a good thing to open the door to operator overloading, in my opinion, messy use case should probably be deprecated and replaced by semantic equivalent methods instead. Even thought I know for a long time that a few operators work with DateTime, it always mind-fuck me in some way. That's a subjective opinion of course, and all your arguments remain legit and valid, you've probably thought the problem much more deeper than I did. At least, I give you that, it will give a rebirth of equals() and compareTo() declined RFCs, and that's something really positive in all that. I'll give it a second read, I might not have seen all recent changes. Thanks for the quick answer. Regards, -- Pierre