Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109507 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40691 invoked from network); 2 Apr 2020 12:04:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Apr 2020 12:04:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E18A91804B4 for ; Thu, 2 Apr 2020 03:31:32 -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=-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-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) (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 ; Thu, 2 Apr 2020 03:31:31 -0700 (PDT) Received: by mail-lj1-f195.google.com with SMTP id t17so2623969ljc.12 for ; Thu, 02 Apr 2020 03:31:31 -0700 (PDT) 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=9NsUmcByqgreH+XzpOCS2NlzfqtcKuDyXLvt2MaYI0U=; b=Qp6uH21GwdZBbNcqhJ71+YJXrariwhurV9Ijd17mU0bnj4Yh1/S5iR1m1rcc9bmY/Y lUWBfv4uSK2dj6PZDPyOE4GaUv1DCjdIuD7MzisxeV8nAeHr4eAGnUxHD/g62PxPlaKP fWpriPaH2K8MtsInpt6RK2lx+wyyD2KuzVTbTB6PdaMpyTSztq+l7mbCyfwWectxbzF6 pAgqLMGLPcEozQp3ITMAJiX+fbz0BRusWkhanO+DMshnXgeO4PLq9lt31mD1taoJu226 1AN1TRaUIDtBSziTG9MfZaDMHiagHYLI/q85t3c2vELChK5iR1/vd5Q0YtKgROUEP441 le3g== 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=9NsUmcByqgreH+XzpOCS2NlzfqtcKuDyXLvt2MaYI0U=; b=BbZVQtU5Y/mBzEXpZlRDaLULqc8t9FNAKy14sr1M2nNwZ1oPdr14o7AIDd3Lw2BPbe cfS6cpjUtEP0w1QEQriQqIfnLTgB/xOFB14dnW8WxuHCGi0sgNZ2ZThTObsNZN4hjH7c y64NHjKnV9QPw/XXP4nxJhG3KKeSCxeabuSLuF8LExTBV71IVUYY3dblhh+/k6sMNvhx bHUzpCSmmWhp/DJjGVRiHRuLiMOxG+mOUH9pXBbv4/6Ll0A2JqazDJZephPtMK/Kn2hF xpx0U0Uk1/hHJUbODtx/CLJsBNU+DaIVKr4DdXpImzi9dDWq66+DQic5rsy6PrZWcTxR K1iA== X-Gm-Message-State: AGi0PubxDM6adqn1bVPLJLffW7IpiFJQAD1CguJoegjCwBTFRpXsg3B4 cXdh9DftKsHsGizTfuo5aylocg6FOTFuwqaVki4= X-Google-Smtp-Source: APiQypI3fTD0t6VxQGJAbDBeLa77KegJTe0BlUXkEe/YuDQAH3013kJgyEp+iZb0RWyb9tnjnrBoMNo4mOn6r2RJH6w= X-Received: by 2002:a2e:9605:: with SMTP id v5mr1555954ljh.258.1585823486918; Thu, 02 Apr 2020 03:31:26 -0700 (PDT) MIME-Version: 1.0 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> <07f176a5c2ff0338cb67c9755bf37af6dcc2d465.camel@schlueters.de> <5e7fbf46.1c69fb81.9d100.8efeSMTPIN_ADDED_MISSING@mx.google.com> In-Reply-To: <5e7fbf46.1c69fb81.9d100.8efeSMTPIN_ADDED_MISSING@mx.google.com> Date: Thu, 2 Apr 2020 12:31:10 +0200 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000009d460b05a24c4da3" Subject: Re: [PHP-DEV] [VOTE] Userspace operator overloading From: nikita.ppv@gmail.com (Nikita Popov) --0000000000009d460b05a24c4da3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Mar 28, 2020 at 10:19 PM Andrea Faulds wrote: > Hi everyone, > > Johannes Schl=C3=BCter wrote: > > > > If we use two methods as well it is a saner design. I won't like it, bu= t > lot better than the current one. > > Just want to +1 this. Two methods, neither of which are static, seems > like a cleaner approach to me. I maybe like this better than my > suggested boolean argument (it certainly looks nicer). > > Consider what happens in the current proposal if a class, intentionally > or otherwise, only supports being on one side of an operator=E2=80=A6 it = will > produce the same error message as if it didn't support the overload at > all :( Could you please expand on what the advantage of using two instance methods over one static method is? As far as I can tell, Python uses this design because they don't really have static methods (let's gloss over the @staticmethod decorator here), so it's basically their only choice. I don't buy your error message argument. Assuming https://wiki.php.net/rfc/arithmetic_operator_type_checks passes, the error you're going to get is something like "Unsupported operand types: int / Vector", which seems reasonable to me, and leaves potential support for "Vector / int" open. The presence of only one of the two method could not be used for the error message anyway, because presence of the method does not imply actual support of the type combination, and we certainly wouldn't want to do a call for the reverse order to adjust the error message. Regards, Nikita --0000000000009d460b05a24c4da3--