Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123020 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 545901A009C for ; Sun, 7 Apr 2024 17:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712509810; bh=WLmL2FWWSsGzm1r8ujuQtcqU/p+6Wm0WaT+vdlQVWWU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=a/xqo7CYbBpa6gLo3CTgQbhznGZEdnBUY3pcHQS14fIlD1tSd8s4/8ITUPzVeW/6g 0T2An5gnwxJ1s/aCtVTJ6CGS0bb0EdTkUo5R3Y4tl/gdx1qoctQ2w6nASu/WkJOSLu GS+bcI9SKjb5TJRhc3gLgjgmf7gNtEojbMuwnGDKVRe4jORbP5JHC97ZPzJx9/4JLn LHi+2Cd19a60FycO0IgKMA3j48S5NBCPO5FaXfICXo+2g4sqWSQYCDjS/gDcitX6/i 0kkcCXo+hmQP1wFBkQaWMdZzvJCxk8ny0/kv7fz0ExsLhTyu7PJDnj58HBngo/4RNe mIt78FHlfNOgQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8AA031801D8 for ; Sun, 7 Apr 2024 17:10:09 +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.7 required=5.0 tests=BAYES_05,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 7 Apr 2024 17:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1712509776; bh=yd8YpePytPsIymLl8z+fPg0AJrQaY48GMiMjqgZWyQs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=nQD2FJxuhIkfn8J0pBKyaA4YzoQDsBn1RzdPsAPZPfDS0C2cNJLerxrZiIGnrP8yt 6iTeHoMJRHEljdSXOpyTvqnbyd93M1U7Aba28/rbSBZQvUFnUtFxAwxw5rxbJcTCDy fuZ22DbRvOUxaO0QJlVjkSfAVhkf7V9sy+NRa/EEX/a8TN0xSf0JF5kJlmCBdsJH0K B9obIFuZ141RNawftRTmqUUoy9hAvYSqnCnmF7cUxUp+2bU79UuNJjBCR1KTHRO3tq AKQcAH/15zVbVQExoCX9quImwvFP7VChd1magnZok3KNWfViwWorfHaeO9nsJXBWGb Bgp2UMiTv+WHw== Message-ID: <959ccc6e-1d5c-48c0-9357-80e38becd1c5@bastelstu.be> Date: Sun, 7 Apr 2024 19:09:34 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath To: Saki Takamachi Cc: internals@lists.php.net References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 4/6/24 17:07, Saki Takamachi wrote: > To you all: > The discussions thus far have been reflected in the RFC. I would be very happy if you could check it out. (Thanks Tim, the tag is very easy to read.) > https://wiki.php.net/rfc/support_object_type_in_bcmath Thank you for the updates. Some remarks: - The namespace is inconsistently referred to as "BCMath" and "BcMath", please check the entire RFC to unify the casing. - The full “stub” should probably include an explicit "implements Stringable" for clarity. - I don't want to expand the scope of your RFC further than necessary, but for the rounding mode, I wonder if we should first add the RoundingMode enum that has been suggested during the discussion of the "Add 4 new rounding modes to round() function" RFC. It would make the type for the `Number::$roundMode` property much clearer than the current `int`. I expect the addition of such an enum to be a pretty simple RFC that would not need much discussion. I'd be happy to co-author it. - The property should probably be named "$roundingMode" instead of "$roundMode". - I'm not sure I like the differing default rounding modes for implicit rounding (i.e. the $roundMode property) and explicit rounding (i.e. the round() method). That sounds like it would cause unnecessary confusion. - In the stub there's a typo: "puclic", should be "public". - For `format()`, I'm not sure whether we should actually add the function. While we have number_format() for regular numbers with the same signature, it fails to account for the different language and cultures in the world. Specifically `number_format()` cannot correctly format numbers for en_IN (i.e. English in India). In India numbers are not separated every three digits, but rather the three right-most digits and then every two digits. Here's in example: 1,23,45,67,890. I believe formatting should be best left for ext/intl. - I'd probably not add the 'with()' method, because it would be redundant with https://wiki.php.net/rfc/clone_with and it can already be specified by a combination of withMaxExpansionScale + withRoundMode. - I'm not sure if the priority for the rounding modes is sound. My gut feeling is that operations on numbers with different rounding modes should be disallowed or made explicit during the operation (much like the scale for a division), but I'm not an expert in designing numeric APIs, so I might be wrong here. - For the RFC Impact on SAPIs, it should simply be "None", because SAPIs do not need to do anything special. - For the Backwards Incompatible Changes, it should list that the BcMath\Number class will no longer be available to userland. Best regards Tim Düsterhus