Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116623 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13766 invoked from network); 12 Dec 2021 07:53:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Dec 2021 07:53:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 66F6A1804AA for ; Sun, 12 Dec 2021 00:55:23 -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=0.5 required=5.0 tests=BAYES_20, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS 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-ed1-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 ; Sun, 12 Dec 2021 00:55:22 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id v1so43277013edx.2 for ; Sun, 12 Dec 2021 00:55:22 -0800 (PST) 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:reply-to :from:date:message-id:subject:to:cc; bh=ClYxVhHYBdRhwD3M+ElqvtNILrKLOmxs9DlYte6aeGQ=; b=ikd8/vmb1MKVD4n0yCjyMUfAL3+UUTw3sLmbz1GRVbpw0doRIS8mwavB3JuZLuP3T7 egIwkjnscloB3GBqVpI1Bxj1+RCSsR5FCP4jxAZTBkiVi//WhIO/IZTzzF4k9o5jU1k/ VB4UWgq0f22b65U1jH81da7783Wme2ol9Am+dc93WqMEgp8rAK9JpKsnNa7BMCokVFH8 29Veta7Q90jUspOGNn6+4CqUmEMeYsPTxg05SOlHSPdwDvFSefdO6K8nEX6cWXYrXl6j HnwK2uZKtg1ye4NHSUqoYupREs4femhiMOUT7mHcjObAq3d88B0Z5zxrYUbYE3a95dtK T6Eg== X-Gm-Message-State: AOAM533BRB16ODgZxgoS3RarYUWjvF09TUyDNKGBHBCuOzWqjTqqhRf2 e3rHMtQeeX2JLZkmlfEi4fmHW4BnF8/Dpg== X-Google-Smtp-Source: ABdhPJz4epew5ipuNvo+NO9Opd+mw0/xqNk1DY6R6oPDSyD2b5AF4/aoIGun4fTAcIWlsc84MX40CQ== X-Received: by 2002:a17:906:1e05:: with SMTP id g5mr38423090ejj.552.1639299321418; Sun, 12 Dec 2021 00:55:21 -0800 (PST) Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com. [209.85.208.50]) by smtp.gmail.com with ESMTPSA id kx3sm4257937ejc.112.2021.12.12.00.55.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Dec 2021 00:55:21 -0800 (PST) Received: by mail-ed1-f50.google.com with SMTP id y12so42061105eda.12 for ; Sun, 12 Dec 2021 00:55:21 -0800 (PST) X-Received: by 2002:a17:906:40c4:: with SMTP id a4mr34301143ejk.185.1639299320854; Sun, 12 Dec 2021 00:55:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: james@asgrim.com Date: Sun, 12 Dec 2021 08:55:10 +0000 X-Gmail-Original-Message-ID: Message-ID: To: Jordan LeDoux Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b33f4505d2ef1d5b" Subject: Re: [PHP-DEV] [RFC] User Defined Operator Overloads (v0.6) From: james@asgrim.com (James Titcumb) --000000000000b33f4505d2ef1d5b Content-Type: text/plain; charset="UTF-8" On Thu, 9 Dec 2021, 20:12 Jordan LeDoux, wrote: > > RFC Link: https://wiki.php.net/rfc/user_defined_operator_overloads I'm not strongly opinionated on either approach (magic __add vs operator +) although I have a very slight preference to your propose operator + syntax, however despite very occasionally thinking that this would be a useful feature, I always start to think about all the awful ways this could be used, making debugging and reasoning about code harder, since unexpected magic behaviour can (and probably will be) introduced. The proposal is technically reasonable, pending consideration of reflection and so on, but I just think the desire to use this in ways it shouldn't be used will be too great, and we'll end up with horrendous complexity. Perhaps I'm too cynical. The only mitigation for unnecessary complexity I can think of is to force overloaded operators to be "arrow functions" to encourage only minimal code, e.g. operator +(Number $other, OperandPosition $operandPos): Number => return new Number ($this->value + $other->value); --000000000000b33f4505d2ef1d5b--