Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122964 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 079071A009C for ; Fri, 5 Apr 2024 11:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1712314993; bh=svBSQwq84ez+1qWBPWoqlDMWga1kTIT8+tkH6JU6cEQ=; h=Date:Subject:To:References:From:In-Reply-To:From; b=Noq/lYZ5PbdD5R6fJg2zORXhvFzOhD96PHdz0FeY1aJWtBMBN84TfhI7cWrPJKT7G Nq25xMVgzrqV0sUlJzJ4M0zU65jmQiIAmopVyLRxfIxiBTvioDmQc9g0TPnaX9u9ga OBKlLUsoJzJM8zQ6JGxLZfrwjW49eVQpp8LKfMhuIAd//WIEqP4Pax16thAxdlIsVO 9B/HHx9LnUz7M+5RZMRdnLXpLx+4KScJBR31I3Xeq2PF4sfZB31F7K0n+XnwPJRY0S PI0S2hVJRtgb6wKM0VphskOrigTxXG9dGpDfBoXn31fxIBRlwRC126qXfS9P1yotwA rZeyXfq3ROrYA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0312B1807CE for ; Fri, 5 Apr 2024 11:03:13 +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=1.0 required=5.0 tests=BAYES_50,DMARC_MISSING, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,SPF_HELO_PASS,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 gliadin.co.uk (gliadin.co.uk [80.82.115.221]) by php-smtp4.php.net (Postfix) with ESMTP for ; Fri, 5 Apr 2024 11:03:12 +0000 (UTC) Received: from [192.168.0.17] (hari-18-b2-v4wan-169870-cust740.vm1.cable.virginm.net [92.239.242.229]) by gliadin.co.uk (Postfix) with ESMTPSA id 9FCE6FA0241 for ; Fri, 5 Apr 2024 14:02:42 +0300 (MSK) Content-Type: multipart/alternative; boundary="------------uusMmLqQF0Gt8lhFy5AxhVQd" Message-ID: <65bac481-628b-49c0-a87e-b54dd466fc0f@redmagic.org.uk> Date: Fri, 5 Apr 2024 12:02:41 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] [Discussion] Support object type in BCMath To: internals@lists.php.net References: <5876c04a-bfed-4a97-be65-f8b64ddef31a@redmagic.org.uk> <1F912518-DE28-4E83-B9AA-AC135822B306@sakiot.com> Content-Language: en-US In-Reply-To: <1F912518-DE28-4E83-B9AA-AC135822B306@sakiot.com> From: barney@redmagic.org.uk (Barney Laurance) This is a multi-part message in MIME format. --------------uusMmLqQF0Gt8lhFy5AxhVQd Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 05/04/2024 09:37, Saki Takamachi wrote: > Hi Barney, > >> Ah ok. Maybe that's the standard way internal classes are written, and we can consider it generally an error for a child class to override the constructor without calling `parent::__construct()`. I know tools warn users not to forget the parent call. > Thanks, A fallback would be possible to always set the initial value to 0, but an error would probably be easier to understand. Uninitialized is miles better than 0 I think. 0 is a meaningful number just like any other and we should very strictly avoid inserting made up numbers into people's applications. Let them fail fast, not output fake data. I'd rather my web shop crashes than gives things away for free. > > >> And I had been thinking of BcNum as a readonly class, but I see it's not an readonly class, it's a mutable class with its one and only property being readonly. I agree that it seems unnecessary to force child classes to be immutable - I wasn't concerned about them adding additional, mutable, properties, only about leaving the value property uninitialized. (Btw I would have supported the 1st part of the 2022 Readonly amendments RFC, which I think would have made a readonly class behave the same as a class where every property is readonly, particularly since would have allowed implementing the example given on the Wikipedia page for LSP: a circle with fixed centre and mutable radius may inherit from an immutable point) > Ah, sorry about that, I completely forgot about the readonly class! In that case, it might make sense to make the classes completely immutable, since users are already accustomed to using such classes. > > This is a departure from what I said in my previous email, but how do you think about making it a read-only class? Tim has convinced me that it should be a final class, in which case there's no meaningful distinction between a readonly class and a class with no mutable properties. In that case just for simplicity I'd say it should be a readonly class. If it's not a final class I think I'm not the right person to ask, since as I said I don't really like the fact that a readonly class behaves any differently to a class with no mutable properties. I prefer the behavior of the latter. --------------uusMmLqQF0Gt8lhFy5AxhVQd Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit


On 05/04/2024 09:37, Saki Takamachi wrote:
Hi Barney,

Ah ok. Maybe that's the standard way internal classes are written, and we can consider it generally an error for a child class to override the constructor without calling `parent::__construct()`. I know tools warn users not to forget the parent call.
Thanks, A fallback would be possible to always set the initial value to 0, but an error would probably be easier to understand.

Uninitialized is miles better than 0 I think. 0 is a meaningful number just like any other and we should very strictly avoid inserting made up numbers into people's applications. Let them fail fast, not output fake data. I'd rather my web shop crashes than gives things away for free.




And I had been thinking of BcNum as a readonly class, but I see it's not an readonly class, it's a mutable class with its one and only property being readonly.  I agree that it seems unnecessary to force child classes to be immutable - I wasn't concerned about them adding additional, mutable, properties, only about leaving the value property uninitialized. (Btw I would have supported the 1st part of the 2022 Readonly amendments RFC, which I think would have made a readonly class behave the same as a class where every property is readonly, particularly since would have allowed implementing the example given on the Wikipedia page for LSP: a circle with fixed centre and mutable radius may inherit from an immutable point)
Ah, sorry about that, I completely forgot about the readonly class! In that case, it might make sense to make the classes completely immutable, since users are already accustomed to using such classes.

This is a departure from what I said in my previous email, but how do you think about making it a read-only class?

Tim has convinced me that it should be a final class, in which case there's no meaningful distinction between a readonly class and a class with no mutable properties. In that case just for simplicity I'd say it should be a readonly class.

If it's not a final class I think I'm not the right person to ask, since as I said I don't really like the fact that a readonly class behaves any differently to a class with no mutable properties. I prefer the behavior of the latter.

--------------uusMmLqQF0Gt8lhFy5AxhVQd--