Re: Proposal: Arbitrary precision native scalar type
| From: | Rowan Tommins [IMSoP] | Date: | Mon, 08 Apr 2024 10:03:56 +0000 |
| Subject: | Re: Proposal: Arbitrary precision native scalar type | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-123035@lists.php.net to get a copy of this message | ||
On 8 April 2024 10:12:31 BST, Saki Takamachi <saki@sakiot.com> wrote:
>
>I don't see any point in "scalar types" that feel almost like objects, because it
>just feels like you're manipulating objects with procedural functions. Why not just use objects
>instead?
Again, I don't think "has more than one attribute" is the same as "feel almost
like objects". But we're just getting further away from the current discussion, I think.
>Sorry, but I have no idea what you mean by "numbers have rounding modes". Numbers are
>just numbers, and if there's something other than numbers in there, then to me it's an
>object.
The proposed class is called BCMath\Number, which implies that every instance of that class
represents a number, just as every instance of a class called DateTime represents a date and time.
In the end, a class is just a type definition. In pure OOP, it defines the type by its behaviour
(methods / messages); in practice, it also defines the properties that each value of the type needs.
So I am saying that if you were designing a class to represent numbers, you would start by saying
"what properties does every number value have?" I don't think "rounding
mode" would be on that list, so I don't think it belongs on a class called Number.
Regards,
Rowan Tommins
[IMSoP]