Supporting object types in BCMath
| From: | Saki Takamachi | Date: | Sat, 16 Mar 2024 05:22:47 +0000 |
| Subject: | Supporting object types in BCMath | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-122651@lists.php.net to get a copy of this message | ||
Hi internals,
BCMath currently only has procedural functions. This is a bit unwieldy for some design patterns and
I came up with the idea of supporting object types like mysqli.
Yet another idea is to also support immutable objects, like DateTime.
e.g.
```
$num1 = new BcNum('1.235');
$num1imm = new BcNumImmutable('1.235');
$num2 = new BcNum('2.001');
$num1result = $num1->add($num2);
$num1immResult = $num1imm->add($num2);
$num1->getValue(); // '3.236'
$num1result->getValue(); // '3.236'
$num1imm->getValue(); // '1.235'
$num1immResult->getValue(); // '3.236'
```
The reason why the class name is not "BCNum" is because it needs to follow the current PHP
naming convention. As an example, the class name of a PDO subclass has a name such as
"PdoOdbc".
I look forward to your feedback.
Regards.
Saki