Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123976 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 1D85B1A009C for ; Thu, 27 Jun 2024 22:12:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719526416; bh=6SvBZKMTi0Izq9rFW2beIWJK6SSL48N21DDxNOceI2g=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=XN31uEtcpR5D5PU5jxiS8CgZVF5oLLGLoo9nRydWT2t8L/CFWxLpjnfumdiIjd4F0 CNcpjXlAxPIopnSdu1NZ6ThQfc8XjEsn5oiuRILOu2J5T6119MiFV02/TziRXNyLxo U8jSIHr6dRAa7QrQQ812Xrg+UH6a43vbfhtyBVGinr3FcgRL6pAloc0rR4/SUI8Y8D j+LV1CdGw5u+UpBXnPLI1Od+Gk6ijVm/Lqt0iJNcIm9ijAPeIZOnE94P7o2VDnNff0 9Eey/4IB3ffDASSkjoKA9HhtdNdlgP0u7N9pPKnD/ZWPBCxdghW4TFHgMCNQ8TUyLB GG7uJOffJ/KJg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 648EF181FFC for ; Thu, 27 Jun 2024 22:13:35 +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 wfhigh1-smtp.messagingengine.com (wfhigh1-smtp.messagingengine.com [64.147.123.152]) (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 22:13:34 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 66D3B1800103; Thu, 27 Jun 2024 18:12:15 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Thu, 27 Jun 2024 18:12:15 -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=1719526335; x= 1719612735; bh=vaM2klksByHi3iuG+AmCj5m6eqSglUqg5seNuj6m4K4=; b=k 6q7e8O3mgy9/WMYvQUlonk3yGeCBnL354Hy6S8Q3PX6oryUUOS3wAaKOu1NHlkaT EDzSmVWM6OWWW6NtWsb5LnqkD+LnGhrSdko9rck7BId6Pje8nW1aNdJzlQ9uXEV6 YG2yEdj13xMGu6qyXZi0ZvdAUyRD8G3kpu8LbrFF996PiY2kg5x0fc+faIZX525k 53hhLPlLdi3bzkJN0BLMjXxVO4/b+AFynjleKydZUzg0D5/40gZK8LPGpsXiISCV Ki9m7JX2a1GT+drm05mPuggY/GLnA9M/ThQvXG6fty84+bcnZh7rOC82t7DjYpN5 9AkMZZGskja4G6/tueSgw== 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=1719526335; x=1719612735; bh=vaM2klksByHi3iuG+AmCj5m6eqSg lUqg5seNuj6m4K4=; b=Q30ULqOMwgpW+HcD/qleuhA2aQXqfCSB50KLyR9id9WU aEDZ+vYX+IidrbxyTX2kCRdQfBITIzrDjPXJpNnU5B2rFYggwtFpu2/qSKQ32tt1 yKX5szGbGwFwSjpYs3uLFKa0RPREbLPT6vyw32+IC/drUzoopitnfPtOYlDOIYJr z5D8J68xvWS3SYTQYgAubnzcg1nFxR+baw/S3sH7JGpvtpZPWdc7gKnku8Apgs9o eyWUX4c9SGc3kddL/UfUPOsnhg71sUf5wEyWYMnk4kRa2cnTg5fBgpXQXxeVIC8y c3pWsLPuP1GI9DQdh4/JdSk+8aP0l4QBOCu1w7s0Tg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrtdehgddtkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesrgdtreerreerjeenucfhrhhomhepfdftohgs ucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrg htthgvrhhnpedvheekteelveetfeevgeekgfffvdeuhfelveehvdetiefggedtfeejheet gffhueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hrohgssegsohhtthhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 612C015A0092; Thu, 27 Jun 2024 18:12:14 -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: <3ea02a19-2171-4ba6-bc64-2c584bc135ad@app.fastmail.com> In-Reply-To: References: <930741fa-eb10-44c6-acbf-34ec9823f8f3@app.fastmail.com> <64BF2EC8-6B0E-4F5E-95C2-F5DE9B71D141@sakiot.com> Date: Fri, 28 Jun 2024 00:11:06 +0200 To: "Jordan LeDoux" Cc: "Saki Takamachi" , "Gina P. Banyard" , internals@lists.php.net Subject: Re: [PHP-DEV] Overriding GMP objects Content-Type: multipart/alternative; boundary=c792a294f32d4577b865ccf591832ab0 From: rob@bottled.codes ("Rob Landers") --c792a294f32d4577b865ccf591832ab0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Thu, Jun 27, 2024, at 23:46, Jordan LeDoux wrote: >=20 >=20 > On Thu, Jun 27, 2024 at 2:35=E2=80=AFPM Rob Landers wrote: >> __ >>=20 >>=20 >> 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 resu= lt of an inherited child class causes several problems. >>>=20 >>> The points raised in the `BCMath\Number` discussion can be summarize= d as follows. >>>=20 >>> - If it is possible to perform calculations on parent Class and chil= d Class, 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 time class. >>=20 >> That would depend on the library=E2=80=99s implementation.=20 >>=20 >>> - Similarly, multiplying two distance classes together should yield = an area class. >>=20 >> See above.=20 >>=20 >>> - 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 the value of the prope= rty, but in that case the commutativity of the computation should be los= t. >>=20 >> This can be handled via the child class in static methods, per the li= brary specifications. >=20 > How is the library supposed to do that in the absence of operator hand= ler functions that can be overridden, or at least called when an operato= r is encountered? >=20 > Jordan That=E2=80=99s what this email is about: adding those functions to the b= ase GMP class as static protected methods. A time class would look something like: static protected add(GMP $left, GMP $right) { if($left instanceof self && $right instanceof self) return new self(pa= rent::add($left, $right)); throw new LogicException('can only add time to time'); } =E2=80=94 Rob --c792a294f32d4577b865ccf591832ab0 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable

=
On Thu, Jun 27, 2024, at 23:46, Jordan LeDoux wrote:
<= /div>


On Thu, Jun 27, 2024 at 2:35=E2=80= =AFPM Rob Landers <rob@bottled.codes> wrote:


<= div>
On Thu, Jun 27, 2024, at 06:07, Saki Takamachi wrote:=
<= div>
I agree with Gina. Being able to change the clas= s of a computed result of an inherited child class causes several proble= ms.

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

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

Ask the class what it 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. 

-&nb= sp;Similarly, multiplying two distance classes together should yield an = area class.

See above. 

- If only child classes have a property that shoul= d be specified in the constructor, how do you determine the value of thi= s property in the result class? Perhaps it is possible to determine= the value of the property, but in that case the commutativity of the co= mputation should be lost.

This= can be handled via the child class in static methods, per the library s= pecifications.

How= is the library supposed to do that in the absence of operator handler f= unctions that can be overridden, or at least called when an operator is = encountered?

Jordan

That=E2=80=99s what this email is about: = adding those functions to the base GMP class as static protected methods= .

A time class would look something like:

static protected add(GMP $left, GMP $right) = {
  if($left instanceof self && $right instan= ceof self) return new self(parent::add($left, $right));
&n= bsp; throw new LogicException('can only add time to time');
}

=E2=80=94 Rob
--c792a294f32d4577b865ccf591832ab0--