Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108991 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 63574 invoked from network); 12 Mar 2020 10:10:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Mar 2020 10:10:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 153631801FD for ; Thu, 12 Mar 2020 01:31:42 -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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (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, 12 Mar 2020 01:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1584001899; bh=TOm307m6yM7MRowvHprZpAfeW41MTeSySqMDjo0hqdo=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=NMVdItAbyb+BJDFWXPhqT7OF6gtts2yb39NDRNQv4fEbw6Kprm+sL52sq77eWxKQL WP93cmxHNRR/bwQUBGcnT76xdX+uTY+6V0MjV0zGkxJoctwcSAC3w/iCD+gBIJ3ua1 PZBJ5/0WqLSNg04FtW1e678fWQG0z9CpkWob3bT0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [10.140.116.64] ([141.35.40.27]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Ml6m4-1jbRv50BUy-00lZ7O; Thu, 12 Mar 2020 09:31:39 +0100 To: "Christoph M. Becker" , Nikita Popov Cc: PHP internals References: <005101d5edae$7b7c3e10$7274ba30$@gmx.de> <8776962f-71ac-0ee3-a1b8-42eb2926eef0@gmx.de> <3ac8a6c1-a4e2-ecc9-053d-1c1a955a0325@gmx.de> Message-ID: Date: Thu, 12 Mar 2020 09:31:38 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <3ac8a6c1-a4e2-ecc9-053d-1c1a955a0325@gmx.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:Oz6gA4WaCEQDhjWMRVOctXJmJMD9pD7aC+yu1qY0Sov+59W4tkK uAM55lhWmWTEJjB8ZPU7yQZsR87p45bs7bApw2iLFGN5kPFwFEO61DJcbog2nkDLniuvWwX cHYq9eHS7okd54dibyLO2MszC2PZ8iWOUipNRAnheEvBA+LgM7I7Wr1TglsTKXpMmNpOULR cnePQSMxi9ki6C8d4eCHA== X-UI-Out-Filterresults: notjunk:1;V03:K0:8pQ1CVoD9DE=:UED4msPPZkOv6I5zbkQuUY erPF3N1SwqEH7o9myaLar57NbyWUf0sOtR7rhyNyzpX59t7cAH8g4hweA0omVm18mGspVhkxy m69qvFRnMkQgr+j7Ui7+ryahzHNOlQmCiISHDdAiXSzXC215MUWOmGm4WVeoxdPMwr5aVk+G/ C8CRFNNESR8GxYIvxKe2qllvChoE/PWkyWVH2SiMVb4mas3+z+V60RYNCeY9Itzjn5muENIja KCrLJDLZ+U0pzRPd/+yCWqYDunLUWqPs/yCINTGcaIkwGNRPVEnt509GiC/8S7ObW/K6b71Z/ c7wBm1Acp7uTKZXI2lHxHV9Xs3LvN+sd4PUENXgGxlTdImBvWYBbwatG8tbAlT/Pato5oRF+w m6gOrHqSPD/CmpvsFNtMmB4GSEor1J+dIyALMEicOwsMo4YNPQb8a+4/mJ7RipbCqJ0IooAx5 zBP+LVwwW8/xTS7sYnY8IcGAFk/Vp6jXDV2d73ZfjmtgyaxXHJGeCQ+hcs2nnSyQFVZlTygrR Fllmp3qr8tC7qF881V/z9aTnicz+//TuXds3TFBZEjvHyAfoXQ2h5/ABlObvpYe7DpMntdsh9 9Fpz8I0QhIGZ0n6ZwZA/KOdGwHRAR5kZ3SJ0FAKQd/ch0NEbnI9Vl6nBHKh/k9/01vcsxBcbC kQnB2yPlIFsScOtzdqdPxgOIqW1XOjz2bFcKJ3sMXb5W71DujN5h2W+itzKkdz2sNbHOXNKGb DPAoIURwWLNZyHuL03WTMIjEBo3QUgJNZAhUk6Zf6TWJyiP2lv5NHYmbNkne4lrTLUiZ+z7Zx rnQQ8xo3H3Xw3RMp63eDsE457U+jAqWQCsijVBdQYEe4W2T9KNC6iCM7g292YU2UQcHjwP7sz +hWrgcpVKY1Xc1vREZLClZXbi9bZhCKW1odK9Ah6xfcES1XGve2iDi7EnJrrsPU8WsfXwAey/ eBWUsHhJEIth1WFoQTnod2utwksDlwO91NcPhg/lh3eIGsoS/fU5teA3gaHxpiZMBEzAYq2qQ Z3M8yKApJGVtU3FHO8EozrgreKG9S6kWB8nZuIVCpsAdJl6MXeEQwGqdsN/l/wWYOWryz7TYW AG/L3CAKqpVZMUebXxAndvz5T6d5Zn3NZ/HF/RB+2ojBixw+e8Hjoil0bzI9b6DggP+jdaOu0 1Ng9xA/YVp9mnWiKrpYPgAf/gjDCyxp6QhU4KKAEfKqzvpA2Uts3+d/TDp4WnnB4DnnqsBh1I H0NKI7l4F7VjY8FGr Subject: Re: [PHP-DEV] Re: [RFC] Userspace operator overloading From: jan.h.boehmer@gmx.de (=?UTF-8?Q?Jan_B=c3=b6hmer?=) On 11.03.2020 at 10:50, Christoph M. Becker wrote: > On 11.03.2020 at 10:22, Nikita Popov wrote: > >> On Fri, Mar 6, 2020 at 9:17 AM Jan B=C3=B6hmer w= rote: >> >>> Am 02.03.2020 um 15:30 schrieb Nikita Popov: >>> >>>> On Thu, Feb 27, 2020 at 9:43 PM wrote: >>>> >>>>> If the operator handler function declares typehints (e.g. public sta= tic >>>>> function __add(Vector3 $lhs, int $rhs)), the function handler is not= called >>>>> if the operand types do not match the signature, and the other opera= nd's >>>>> handler is tried to call. >>>> I'm somewhat skeptical about this. This smells of method overloading,= and >>>> we don't do method overloading. There is no other place in PHP that w= ould >>>> perform dispatching based on the method signature, even if in this ca= se >>>> it's not a choice between multiple methods on the same class, but rat= her >>>> multiple methods on different classes. Some of the usual problems of = method >>>> overloading don't apply here (in particular, one could make a reasona= ble >>>> argument that the method on the first object should be chosen, even i= f >>>> there is a more specific signature available on the second object), b= ut I'm >>>> skeptical about introducing this kind of special case in the language >>>> specification. >>> Your point about the "smell of method overloading" is interesting. In = my >>> opinion this mechanism makes it a bit easier to use operator overloadi= ng as >>> you dont have to do tedious typecheckings on your own in simple cases.= But >>> I agree that this behavior is a bit odd compared to other PHP features= . >>> >>> That feature is not really needed for operator overloading, as you can= use >>> the PHP_UNKNOWN_OPERAND_TYPES const for signaling that the handler doe= s not >>> support the given types. If you (the internals developers) says that t= his >>> does not fit into the concept of PHP, I will remove it from my RFC (or= put >>> it in a separate votation, if wished). >> Does anyone else have thoughts on the ability to specify the supported >> types in the signature? > I agree that we should not introduce (this special case of) overloaded > functions. > > Thanks, > Christoph I have thought about this the last days, and I agree with you. Therefore I have removed this feature from the RFC. If PHP perhaps gets real function overloading someday, we could consider then to integrate operator overloading like in other languages (a separate handler for each type combination), which would be much more useful than the mechanism I had proposed. If there are no other open discussion points, I would put the RFC to voting in the next days. Thank you for your feedback, Jan