Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109395 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 4030 invoked from network); 28 Mar 2020 18:02:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 Mar 2020 18:02:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F19AD1804D0 for ; Sat, 28 Mar 2020 09:27:45 -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.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS31103 84.19.160.0/19 X-Spam-Virus: No X-Envelope-From: Received: from mail.toneristzuen.de (mail.toneristzuen.de [84.19.169.162]) by php-smtp4.php.net (Postfix) with ESMTP for ; Sat, 28 Mar 2020 09:27:45 -0700 (PDT) Received: from maniacmansion.fritz.box (ppp-188-174-60-166.dynamic.mnet-online.de [188.174.60.166]) by mail.toneristzuen.de (Postfix) with ESMTPSA id 361B549A14; Sat, 28 Mar 2020 17:27:44 +0100 (CET) Message-ID: <07f176a5c2ff0338cb67c9755bf37af6dcc2d465.camel@schlueters.de> To: "Christoph M. Becker" , Arnold Daniels Cc: PHP internals , jan.h.boehmer@gmx.de Date: Sat, 28 Mar 2020 17:27:43 +0100 In-Reply-To: <705aba69-8c17-f882-19fd-6f41a2c2ca25@gmx.de> References: <003701d6013c$9afe9750$d0fbc5f0$@gmx.de> <7a83f950a31d94d5ff2307ac8219db3b7b6482b6.camel@schlueters.de> <12ad7c71-8958-7742-12c4-e83e359c8186@gmx.de> <3B71F74D-8142-48FB-9660-835B08D1DDDD@schlueters.de> <705aba69-8c17-f882-19fd-6f41a2c2ca25@gmx.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] [VOTE] Userspace operator overloading From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Sat, 2020-03-28 at 17:05 +0100, Christoph M. Becker wrote: > On 28.03.2020 at 15:57, Johannes Schlüter wrote: > > > On March 28, 2020 1:25:11 PM GMT+01:00, "Christoph M. Becker" < > > cmbecker69@gmx.de> wrote: > > > > > This "try left/right" approach is how operator overloading works > > > for > > > internal classes[1], and apparently, it works quite well, as long > > > as it > > > is not overused. > > > > The fact that it works in one or two cases as an implementation > > detail where the full implementation is controlled by a single > > group (internals) is no indication for it to work at large. > > Fair enough. But maybe Python, where userland operator overloading > works similar to the proposal at hand, is? :) It doesn't: Python 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... def __add__(self, other): ... print("add") ... >>> a = A() >>> a + 1 add >>> 1 + a Traceback (most recent call last): File "", line 1, in TypeError: unsupported operand type(s) for +: 'int' and 'A' johannes