Re: Overriding GMP objects
| From: | Jordan LeDoux | Date: | Thu, 27 Jun 2024 21:46:42 +0000 |
| Subject: | Re: Overriding GMP objects | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123972@lists.php.net to get a copy of this message | ||
On Thu, Jun 27, 2024 at 2:35 PM Rob Landers <rob@bottled.codes> wrote:
>
>
> 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 inherited child class causes several problems.
>
> The points raised in the
BCMath\Number discussion can be
> summarized as
> follows.
>
> - 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 the
> time class.
>
>
> That would depend on the library’s implementation.
>
> - Similarly, multiplying two distance 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 the value of the property, 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 library
> specifications.
>
How is the library supposed to do that in the absence of operator handler
functions that can be overridden, or at least called when an operator is
encountered?
Jordan