Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122651 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 567301AD8F6 for ; Sat, 16 Mar 2024 05:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1710566605; bh=nOcRLO7mLr/YydTR624Gqi/JciaNLcWn5uOLns1dTZA=; h=From:Date:Subject:To:From; b=G1GXQisMtZfhYBZwk2GGH9rp4NzSgIjPx+XgiovW078EqzVnRxvTYw1LolioRXV7i OpmPzXMxm9XtMA+uo+G5QjsoCDfl7z3CzM184fdX96LzXdiOuwlM1fk7y2D54UY/w5 eoYgUdAbcLauA3Bp88Tt/2h0S3P+G0g3IpRWc+BA8aA0waAKTf18lR2h7T/Pc6Bked 8tWqc3oGgufvInAqS2xFz3hFyqEY0HlOk3WmUgt5C/LQnX7IeLadX3707Fkpza2PEO xahHIO1Ne9JLuNXj9zIQCo7c8knNQQDw7bW5tbT2morL2nHRNqW82R6EKhK1PYhcQy aDQcDV8y/XwNA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DFCB8180076 for ; Sat, 16 Mar 2024 05:23:23 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 16 Mar 2024 05:23:23 +0000 (UTC) Received: from smtpclient.apple (178.198.214.202.rev.vmobile.jp [202.214.198.178]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id 974F5401E7 for ; Sat, 16 Mar 2024 14:23:00 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1710566580; bh=nOcRLO7mLr/YydTR624Gqi/JciaNLcWn5uOLns1dTZA=; h=From:Date:Subject:To:From; b=gUwwx82sjzs1vmkbAaczlesaiMm8t3fFh3FR7XIyz516JeQ3vJw5hHo7tPP54ShWz ItAOWw5RyKsckyr/bXffGunktopN7jVNVqdnf9Bisx8uA+6WSh/o4k/aGL1w2TihwM BCQbiqHwf30TGEBjGdse8qH02ScoqQ33PXlHZ/kA= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (1.0) Date: Sat, 16 Mar 2024 14:22:47 +0900 Subject: [PHP-DEV] Supporting object types in BCMath Message-ID: <6253DBFE-CF26-4189-AB9A-8233E411276F@sakiot.com> To: php internals X-Mailer: iPhone Mail (21D61) From: saki@sakiot.com (Saki Takamachi) Hi internals, BCMath currently only has procedural functions. This is a bit unwieldy for s= ome design patterns and I came up with the idea of =E2=80=8B=E2=80=8Bsupport= ing object types like mysqli. Yet another idea is to also support immutable objects, like DateTime. e.g. ``` $num1 =3D new BcNum('1.235'); $num1imm =3D new BcNumImmutable('1.235'); $num2 =3D new BcNum('2.001'); $num1result =3D $num1->add($num2); $num1immResult =3D $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 t= he current PHP naming convention. As an example, the class name of a PDO sub= class has a name such as "PdoOdbc". I look forward to your feedback. Regards. Saki=