Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108619 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 42677 invoked from network); 16 Feb 2020 14:13:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Feb 2020 14:13:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9ADE5180504 for ; Sun, 16 Feb 2020 04:28:26 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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, 16 Feb 2020 04:28:25 -0800 (PST) Received: by mail-ed1-f45.google.com with SMTP id r21so17146743edq.0 for ; Sun, 16 Feb 2020 04:28:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I0rWoRXtPjV5+TWrmDwWE7oNSbe9BhSajkdlGdGWY18=; b=BZzXMKaNpTYM083drwcIAnS9qYigBj5alJmmh2K98CPjKOvYK4d6Jg1C8KfsszRa3d gC2K14qWvnAPl/YuwJLO3RWX1uniobnhDTURjQxZYjzE4XZ6sUk0dNSUsIeL20ejVRi2 Q8n6gcU8lDiJIeB2Ja9rmRl3mv8qhlF/OqnpENBQwJRf8EJNGZro7CYAC5rmxf7E3z81 MR2nyXFV+edDvo9QJ1fsdhM2kd/eplO2JUtVSW6ZSV5t7+wHjJBTZBe2HP6cO6Hdn0PX 6WnPahrghrc9ZNn5BbY1Gd43L8OpiupkSJuAqTMCsHylz55sxau8PjB0gymV0TybPVsw xxXw== 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=I0rWoRXtPjV5+TWrmDwWE7oNSbe9BhSajkdlGdGWY18=; b=h7XYpIE0Dkglk7GrTWmvuUDh6EI9kqrMaji3dIieG6WhAI8iuOfC52cYXE0meJ088/ Q8kE7Z7njecxh4C1mbW7H4kq+7PLmggqYNn0NfwFSMTszawDc8ikEnZu6CKoaewuayQ0 KUtd6tWMphmjXx5uW756947zNDd7ebiS5RVi1HofFvTXHDVTQ6cseX7XIDV5xE8MUL7V ZfpxnEO9O0VJwCKMC+1aQf5v7zQJwAB0FDeopr86Fqnp9CRZSdleVYaW8gcosUlFzMNz 9q3Hp+Iz3Ll8YLFKtnNofSzWSQUlIyyMe8bAPjacpfCewpVgjHYAWx/TAoJcPnsDDNsI vanQ== X-Gm-Message-State: APjAAAUECdpo+gITHhvWWOPp8e9mib8PiwXYRIsK6t6tA5sT5Is7KWfJ /mHrdP/jFRSaG5TOgzovXP265eXCPheeCVQIUih0P/be X-Google-Smtp-Source: APXvYqzW2gCrPWJXh0lpScOBMbN9gCHUiVLPhnJCroJLJYS6ByMUDwtA26YbKWd0tKgLROZ94ClbGpMjYHj5kTpgjTw= X-Received: by 2002:aa7:d145:: with SMTP id r5mr10306024edo.337.1581856103189; Sun, 16 Feb 2020 04:28:23 -0800 (PST) MIME-Version: 1.0 References: <003801d5e44c$169700e0$43c502a0$@gmx.de> In-Reply-To: <003801d5e44c$169700e0$43c502a0$@gmx.de> Date: Sun, 16 Feb 2020 13:28:10 +0100 Message-ID: To: jan.h.boehmer@gmx.de Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000001dd083059eb093f3" Subject: Re: [PHP-DEV] [RFC] Userspace operator overloading From: george.banyard@gmail.com ("G. P. B.") --0000000000001dd083059eb093f3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 15 Feb 2020 at 23:06, wrote: > Hi internals, > > based on the discussions here (https://externals.io/message/108300) and > here > (https://github.com/php/php-src/pull/5156), I have created a proper RFC > for > userspace operator overloading: > https://wiki.php.net/rfc/userspace_operator_overloading > > The main differences to my original concept, is the removed __compare() > method (comparison overloading is a complex topic and should be handled i= n > a > different RFC) and the possibility to signal that the operator handler do= es > not support the given types (by typehints or returning a special value). > This way, only one of both objects has to know about the other type. This > should expand the use case of operator overloading compared to my old > concept. > > What do you think about the RFC? > > Some discussion points, I can think of, would be the naming of the method= s > (maybe naming them after the operator symbol and not the arithmetical > operation they represent, e.g. __plus instead of __add) or putting the > methods inside of interfaces like done for ArrayAccess (But I don=E2=80= =99t see any > advantage in doing so, as it is very difficult grouping different operato= rs > in a single interface usefully. Also, operators can accept and return > different types, so there is no real common interface between classes you > could rely on). > Furthermore, maybe the idea of allowing operator overloading in general > should be discussed as it is sometimes considered an anti-pattern (e.g. t= he > usage of '<<' for outputting a string in C++). On the other hand there ar= e > many languages and libraries where operator overloading is used > successfully > (e.g. numpy in Python). > > Regards, > Jan B=C3=B6hmer > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > Just as a FYI, I'll vote No to this RFC regardless of arguments as I find operator (and method) overloading a bad idea in general. Moreover, the only ones I a= m a tiny bit less reluctant to overload are the mathematical operators. However, one of the major reasons to want to have this seems to add better support for Matrices and Complex number which can already be done at the extension/engine level. Best regards George P. Banyard --0000000000001dd083059eb093f3--