Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123970 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 179541ADB9F for ; Thu, 27 Jun 2024 21:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719523553; bh=DFHA98MLRKQFrEQD0kPP8A3qYe/xRQTUJcxbIXQXA6I=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=fG7ZISfrV7SuZ9Ox+HHVPlzTipHUYrOhcITyDceEbwOL9L3hQCUyK1jwQGJlb5Psp SrFyiHWw9mecDAooZHAY3umUM09LQ39DiWix6EnZMDXuwuax7VLwO7nDjltM1XW6L6 a0D71lRn24VqjQojZruROOloLpbjr3vrSborFmoHrNyF1DOMg6lkuXbSZTsLY9Jy5B F5MVVXb31i1rXSPm42oqwTsCZqT63MUEJ63ryKZmGJPSNkAFsnrpg5XCHOwMr9q2s6 xIzwHPK4MEBkj5IXncP7NjloAt138RuWKtMqlQO+M6hleNwjRID9qDKvgTwnBa6ONq LJkYeK34Oo2GQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B9EB418057A for ; Thu, 27 Jun 2024 21:25:50 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,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 wfout1-smtp.messagingengine.com (wfout1-smtp.messagingengine.com [64.147.123.144]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 27 Jun 2024 21:25:47 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfout.west.internal (Postfix) with ESMTP id CB6B01C000BB; Thu, 27 Jun 2024 17:24:27 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Thu, 27 Jun 2024 17:24:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1719523467; x= 1719609867; bh=DFHA98MLRKQFrEQD0kPP8A3qYe/xRQTUJcxbIXQXA6I=; b=C NrVobf1Ok9Stfzxgq5Tdx7XUOEHTWqFtYMUqoWYbPPll6Y+NIqgi0OkLPiSe3+XH 2i9TfrAwcdb9JK4WwhsjyJHllD6NP8VxTD1+Iy+zSM5widbPzhtpxmesB2ZPE1iw fgZb7jrXCDlfT4jab/vCiqij1LG3ZpeOFUuuWwbT24mDiCiK3+u6tGJd/YnU/2vU MVtHmaCawTZn0cQEl9GU3kBe9uM1gjjGsIiUpCqr32/mQ40D3OTvVL97OktUlBN6 TtCS/dy4uT94zVoYnAYoUGAG3KdCGmcNldF8x4TitePUhRmh3RhLUHC6xs24nuSz 7Yz2wKAEhY5rFSxWyfY5A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1719523467; x=1719609867; bh=DFHA98MLRKQFrEQD0kPP8A3qYe/x RQTUJcxbIXQXA6I=; b=bnllCmc/sPR1ZEpXrHHI48Pcb9EC4GKxXIZj9Bc7WKrI YHtHEbGCDzYCiGPIr8sFgO8Jc6KbhkUHLhoDoC6rj8l+QYMSuRtqHQIFh5cCSDjp 7JphQP38EzXi/Ov4Fy5Pf44nVPpFgQIf3GMXpQhgT4tUHVordu4EWHKS08tKMU32 FAkWgQwf5MjajaMU+f1jS4sO26ZvLPCk604nhktnF5S5E1VCZtHci5cbt+rdp7+x QvNnZ/y3KBgbSdemXdMWKTE/B2oTW5prWET2Il74R6L0dplJAYBP2TQt3/LOFAgC nW3ZQ9yRx+ENCQdurpTuVsfIViPMZirYPDrT780Piw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtdeggdduieduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsegrtderreerreejnecuhfhrohhmpedftfho sgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecuggftrf grthhtvghrnhepvdehkeetleevteefveegkefgffdvuefhleevhedvteeigfegtdefjeeh tefghfeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprhhosgessghothhtlhgvugdrtghouggvsh X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id E028C15A0092; Thu, 27 Jun 2024 17:24:26 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-538-g1508afaa2-fm-20240616.001-g1508afaa Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: In-Reply-To: <64BF2EC8-6B0E-4F5E-95C2-F5DE9B71D141@sakiot.com> References: <930741fa-eb10-44c6-acbf-34ec9823f8f3@app.fastmail.com> <64BF2EC8-6B0E-4F5E-95C2-F5DE9B71D141@sakiot.com> Date: Thu, 27 Jun 2024 23:24:00 +0200 To: "Saki Takamachi" , "Gina P. Banyard" Cc: internals@lists.php.net Subject: Re: [PHP-DEV] Overriding GMP objects Content-Type: multipart/alternative; boundary=8b020523d27245b6be190546e9c77460 From: rob@bottled.codes ("Rob Landers") --8b020523d27245b6be190546e9c77460 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 follows. >=20 > - If it is possible to perform calculations on parent Class and child = Class, what should the resulting class be? Ask the class what it wants to be? > - Multiplying the distance class and the speed class should give you t= he time class. That would depend on the library=E2=80=99s implementation.=20 > - Similarly, multiplying two distance classes together should yield an= area class. See above.=20 > - If only child classes have a property that should be specified in th= e constructor, how do you determine the value of this property in the re= sult class? Perhaps it is possible to determine the value of the propert= y, but in that case the commutativity of the computation should be lost. This can be handled via the child class in static methods, per the libra= ry specifications. >=20 > These problems cannot be solved without significant complexity. And th= ere is a possibility that it cannot be resolved in the first place. I very much disagree; there is very little complications in the extensio= n. It=E2=80=99s actually quite simple: If one value is scalar and the other an instance of GMP, for binary ops,= ask the GMP class to perform the operation. (This is a one-linish chang= e) If both are GMP instances, in a binary op, ask the left-most one to perf= orm the op. The default GMP implementation will delegate to the right-si= de if the right side isn=E2=80=99t a base-GMP instance, otherwise, busin= ess as usual. And that=E2=80=99s pretty much it, other than defining the base-type ops= . From there, you can implement any units library you want, with whateve= r behavior makes sense =E2=80=94 so long as the base representation is a= number. If I remember the original operator overloading RFC, this is exactly wha= t was asked for by the people who voted no. In theory, it should pass if= brought as an RFC.=20 =E2=80=94 Rob --8b020523d27245b6be190546e9c77460 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Thu, Jun 27, 2024, at 06:07, Saki Takamachi wrote:
=

I agree with Gina= . Being able to change the class of a computed result of an inherit= ed child class causes several problems.

The= points raised in the `BCMath\Number` discussion can be summarized as fo= llows.

- If it is possible to perform = calculations on parent Class and child Class, what should the resulting = class be?

Ask the class what i= t wants to be?

-&n= bsp;Multiplying the distance class and the speed class should give you t= he time class.

That would depe= nd on the library=E2=80=99s implementation. 

- Similarly, multiplying two distan= ce classes together should yield an area class.

See above. 

- If only child classes have a property that should = be specified in the constructor, how do you determine the value of this = property in the result class? Perhaps it is possible to determine t= he value of the property, but in that case the commutativity of the comp= utation should be lost.

This c= an be handled via the child class in static methods, per the library spe= cifications.


<= /div>
These problems cannot be solved without significant complexity= . And there is a possibility that it cannot be resolved in the first pla= ce.

I very much disagree; ther= e is very little complications in the extension. It=E2=80=99s actually q= uite simple:

If one value is scalar and the= other an instance of GMP, for binary ops, ask the GMP class to perform = the operation. (This is a one-linish change)

If both are GMP instances, in a binary op, ask the left-most one to pe= rform the op. The default GMP implementation will delegate to the right-= side if the right side isn=E2=80=99t a base-GMP instance, otherwise, bus= iness as usual.

And that=E2=80=99s pretty m= uch it, other than defining the base-type ops. From there, you can imple= ment any units library you want, with whatever behavior makes sense =E2=80= =94 so long as the base representation is a number.

If I remember the original operator overloading RFC, this is ex= actly what was asked for by the people who voted no. In theory, it shoul= d pass if brought as an RFC. 

=E2=80=94 Rob
--8b020523d27245b6be190546e9c77460--