Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123981 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 5AE671ADA72 for ; Fri, 28 Jun 2024 00:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719535503; bh=d8/EuHysc3EV+aNhBChUg4iKKqSCsLMqBnOLBKWkYDU=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=ArqkxCiCOaIqbF96JBkKK+vMBhLKloZ+7kAZSsAJzYWZnoyM504qdC06JaWRxxzer 57+to8m2bqsqJBdFO7QaRi+qJ0w6fFVeVQtCU5rTwQOSdgriztqg+ZFRuRIFGFnxtq SMV8IQHbw8WlAcI+g95h0n2ajyTI8oFRaHuCMC7S1sRFwNx9QvJy8msKCcepTcGx4M 5R3eUvN/brdvKV42eferbKhPToYmOV5nu5GLhVapCm59nxqe2vUgMMXSYbiBCmNKPZ GA/MxaCz4q33Y6hVk+ZXK6ItZeNBmD4VWz8KhMV6ufkNzkmQgjtW+XXf8awtlbfyM/ UnnoAs5QCoeNw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 370E9180056 for ; Fri, 28 Jun 2024 00:45:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 28 Jun 2024 00:45:01 +0000 (UTC) Received: from smtpclient.apple (228.210.49.163.rev.vmobile.jp [163.49.210.228]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id C9F794011B; Fri, 28 Jun 2024 09:43:39 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1719535419; bh=d8/EuHysc3EV+aNhBChUg4iKKqSCsLMqBnOLBKWkYDU=; h=From:Subject:Date:References:Cc:In-Reply-To:To:From; b=qUPDRh29ba2eTyyFYmlywNr9aHxb5TRImLLMavc6nB+e56SOuhPvo3yWKdK6FEooC U+JzU0O7q6GgeF1/g0Xkj7XGpnMSbz/GEuf2cV1SaiVN6f90Vd1SnnbvSiKU4pt6oX mCsyozADAxsKpZg75jyeneenSZPMsr+3Kw5oBbfw= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (1.0) Subject: Re: [PHP-DEV] Overriding GMP objects Date: Fri, 28 Jun 2024 09:43:26 +0900 Message-ID: <38C21842-1740-48A2-B2F1-0FFA57D542F4@sakiot.com> References: Cc: "Gina P. Banyard" , internals@lists.php.net In-Reply-To: To: Rob Landers X-Mailer: iPhone Mail (21F90) From: saki@sakiot.com (Saki Takamachi) Hi Rob, >> On Thu, Jun 27, 2024, at 06:07, Saki Takamachi wrote: >>=20 >> I agree with Gina. Being able to change the class of a computed result of= an inherited child class causes several problems. >>=20 >> The points raised in the `BCMath\Number` discussion can be summarized as f= ollows. >>=20 >> - If it is possible to perform calculations on parent Class and child Cla= ss, what should the resulting class be? >=20 > Ask the class what it wants to be? >=20 >> - Multiplying the distance class and the speed class should give you the t= ime class. >=20 > That would depend on the library=E2=80=99s implementation.=20 >=20 >> - Similarly, multiplying two distance classes together should yield an ar= ea class. >=20 > See above.=20 >=20 >> - If only child classes have a property that should be specified in the c= onstructor, how do you determine the value of this property in the result cl= ass? Perhaps it is possible to determine the value of the property, but in t= hat case the commutativity of the computation should be lost. >=20 > This can be handled via the child class in static methods, per the library= specifications. >=20 >>=20 >> These problems cannot be solved without significant complexity. And there= is a possibility that it cannot be resolved in the first place. >=20 > I very much disagree; there is very little complications in the extension.= It=E2=80=99s actually quite simple: >=20 > If one value is scalar and the other an instance of GMP, for binary ops, a= sk the GMP class to perform the operation. (This is a one-linish change) >=20 > If both are GMP instances, in a binary op, ask the left-most one to perfor= m the op. The default GMP implementation will delegate to the right-side if t= he right side isn=E2=80=99t a base-GMP instance, otherwise, business as usua= l. >=20 > And that=E2=80=99s pretty much it, other than defining the base-type ops. = =46rom there, you can implement any units library you want, with whatever be= havior makes sense =E2=80=94 so long as the base representation is a number.= >=20 > If I remember the original operator overloading RFC, this is exactly what w= as asked for by the people who voted no. In theory, it should pass if brough= t as an RFC.=20 >=20 > =E2=80=94 Rob I see. All of what I wrote are problems that arise when php doesn't provide a way t= o control them in userland. Your proposal implicitly allows operator overloading in userland. So your proposal essentially amounts to allowing operator overloading only f= or GMP classes. If I understand correctly, this discussion is not centered on GMP, but on th= e topic of limited exposure of operator overloading functionality. I believe this is something that requires some very careful discussion. Regards, Saki=