Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108969 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 8092 invoked from network); 11 Mar 2020 11:29:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Mar 2020 11:29:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C5E771804DF for ; Wed, 11 Mar 2020 02:50:33 -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.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,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.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 11 Mar 2020 02:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1583920231; bh=t/+ibvHuTJA3a0eEZd3HVPB3XNxmNyYCcXKfPqsP5yw=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=FeCzDq2rxzYeUesRNwCAZPn1w9RezGMaMRsNat9IN/oOLRcj//xART0aZHHOPQplx NnySs6TG7UASNVfGCTKZ6BfjUHOS6Z6SksvFmelxvVI1xtIrsHMjcBDCPO2mUCCtWN IHBKTB6vF2FNfa88IOxFN9TYU+jOlyUEyjgN3vyY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([84.179.232.93]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MdefD-1jlItK11AP-00Zk4f; Wed, 11 Mar 2020 10:50:31 +0100 To: Nikita Popov , =?UTF-8?Q?Jan_B=c3=b6hmer?= Cc: PHP internals References: <005101d5edae$7b7c3e10$7274ba30$@gmx.de> <8776962f-71ac-0ee3-a1b8-42eb2926eef0@gmx.de> Message-ID: <3ac8a6c1-a4e2-ecc9-053d-1c1a955a0325@gmx.de> Date: Wed, 11 Mar 2020 10:50:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:h5tEDJgQZyT9PTfWQZGWZH8u8RuMKxt9m1ihFnKqL2l6SPlDTAD gT2UwxKLryfAMlFxuJZfZwGmNIUnz+X+goHMTfRtWsW6N/yfXGC0e+9bm3LwzMpMDsp3BHv /XLsnWtX5UqZVpwdxj7YByc0hxpvFbGb48P50EOYMuNyIsAGJ4SACBvxuNU1YKCwAEEHJ3n hrlvkYQpkVZJTtZkj/FjA== X-UI-Out-Filterresults: notjunk:1;V03:K0:TXk+osU62X4=:hEglQTJJxpS7rEMJ9WrUtW QjlypSMWeXeTfmkmC+uspnAZ/eN9AgRp5SttseJO7k3pKdYF8jM4Xi7cPS4vZXLYcmShcl01J NzTvR27HbIDi+jKSPuxNISRCLrZn4k9gNCemY7xLiwPR1gBpAmUGj2Z4FyVeSb6d601OSot9s 8A832vnrBnBhxv/Sz6N358dKfI21f2CacwKhGR26YRZgn5/BsKBkBuMhOA3m8ywfxFaPGLXrz s6oBZLJlOZrGqSZ/Kki+UbWf8O61c668YZOUDJZqBTKuc62JKBhfK7EZoYORcu6R/HkP6afVa L4qSejU4hTN+gYYzy+2iluISiN/7Z//iqCdi12UaX5w4DlxMSHveDyyika8tbBn3JzzeMt+7j f8H2tZF0aC4GKjNxuy3Uc7W0UfI1Fy3eU8i4kXUQR4921KLN5KNURtyJd1MP+07u1ksM+yJqx x1SyQCSykU2XOUcMxrlVkYB0xiFfbQbKknOcSj5QqHyYZVkPCJ/LGm98x9R5TYL/6s3IMiXb8 XCVIj7UGL2B0UN403hLDoecewaJ/VCTgu+Eb3QDypxXvifLSPNjXa3G26D2vnDbfbzg54Hqjl TuZcOvj8GCmQ15x0sD5L4F5Jui07uuL6GMP0REIu+xajk3JvGsWdpUKu6mQmCnwMWSxfSCVWf onBG01/yNYJx2ZFuzSA7KWDwc93WOhIM6LW4DT0DKsryIAnnxuxIYH4+1yC0cdWXVseWZLqVJ BbjDe1919bfwfUpwWZaNPiGXUVXI/hHhUEY0d77lEbblv8LCihhfW5gQLaiqRTog33H879g4b HHwbndLDe1cFwoyAfrnZix1yPlqG/qwBcB38nwSypnvm47VqC/KjwpfIpmZLsVJ2iKSpWVQnd j9BzQV5XjvL1gO2wZ7bgQ7u32QovmuUWqZLthWkeE0DayF16I+PLxxg7MnUjMXQA/Fv1lUAwB dFcAPVcNnzP1dQwMIt/UFhqzkLHDzAQdTRWsRtf+ucTm9ZsV4gQUBElqaT/c80PU2+QBc0qeX GQqPl6S2A4XgSwHGhbx8Htj1lGBSMt+nCpj78bwT4HzIBrqdwUpMEe0WZnfKOtWg6qFWDIxp1 t4vCnXvZ5vq9zPRwC1fqvCbdKY5vp7DDBI8RW9Zyfj4JQfDBxjG9JBpBAwwC13wSXNrxPw5ZI OKHEotIQ4Q04n+pXuyD9j3UbC5MpJH8eQY3mCETTZw2sT3qFRZETew1KGOZzCE/Rx2bdnC3nB fiY0jUHWKnnu/vEJi Subject: Re: [PHP-DEV] Re: [RFC] Userspace operator overloading From: cmbecker69@gmx.de ("Christoph M. Becker") On 11.03.2020 at 10:22, Nikita Popov wrote: > On Fri, Mar 6, 2020 at 9:17 AM Jan B=C3=B6hmer wr= ote: > >> 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 stat= ic >>>> function __add(Vector3 $lhs, int $rhs)), the function handler is not = called >>>> if the operand types do not match the signature, and the other operan= d'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 wo= uld >>> perform dispatching based on the method signature, even if in this cas= e >>> it's not a choice between multiple methods on the same class, but rath= er >>> multiple methods on different classes. Some of the usual problems of m= ethod >>> overloading don't apply here (in particular, one could make a reasonab= le >>> argument that the method on the first object should be chosen, even if >>> there is a more specific signature available on the second object), bu= t 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 m= y >> opinion this mechanism makes it a bit easier to use operator overloadin= g 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 does= not >> support the given types. If you (the internals developers) says that th= is >> 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