Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107654 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 56813 invoked from network); 24 Oct 2019 14:18:55 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 24 Oct 2019 14:18:55 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 7CEFF2C0499 for ; Thu, 24 Oct 2019 05:05:18 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3265 194.109.0.0/16 X-Spam-Virus: No Received: from lb2-smtp-cloud9.xs4all.net (lb2-smtp-cloud9.xs4all.net [194.109.24.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 24 Oct 2019 05:05:17 -0700 (PDT) Received: from [IPv6:2001:983:6fc5:1:3cbd:5793:795b:352d] ([IPv6:2001:983:6fc5:1:3cbd:5793:795b:352d]) by smtp-cloud9.xs4all.net with ESMTPA id NbreitoRwsBskNbrgirFiZ; Thu, 24 Oct 2019 14:05:16 +0200 To: Rowan Tommins , PHP internals References: Message-ID: <5f8115ce-0f89-c401-c8b8-9f865e76edd3@xs4all.nl> Date: Thu, 24 Oct 2019 14:05:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfBrUqx+SLlgIpPzc2No9HVlW4ZR3Z1oKCbxxqX3fU+lsLXAfRgWaRu7yp+zKdSCmSj3erEYPiK/4I3hmbiLDWLbno5MU1l+725ApBhSfVXiVB7qnnOT3 YPAsON1u2FrDDoWppppiBWYb+eJJKSNZbl0CzA3y9XCE1vFQNXzdPk6vgvwlh4oY2A8oF5II0mG3TLW5c9OS8ZRwXhr/s5lK7GI6EMhjCUG52BzvasqiD+XL APCyS3yFXmtpsOBJymQzqEPQsqQ67aj5ZcQ/YRsgGZytLeXme0aB6XO/FQKRiiRvkBYpP9wLnczsUYT5+anz7g== X-Envelope-From: Subject: Re: [PHP-DEV] Reclassifying some PHP functions warning as exceptions From: d.takken@xs4all.nl (Dik Takken) On 21-10-19 18:02, Rowan Tommins wrote: > There is no general way to know whether the result of aborting execution > completely is better or worse than carrying on with unexpected values. In a > program that's not expecting it, either one could lead to data loss or > corruption. I would guess that carrying on with unexpected values is worse because it happens more often. Checking for false or null is something that everybody forgets all the time. Exceptions are more explicit and an IDE will point you at places in your code where you forgot to either handle or delegate them. > There are definitely places where a Warning can reasonably be converted to > an Exception; but I don't think this should be done as some kind of bulk > change. Each Warning we promote should have at least one person answer the > question "is it likely that terminating processing when this happens at > run-time will be better than flagging a Warning and returning a defined > value?" I fully agree. However I think the fear of having to add tons of try / catch to existing code is exaggerated. I use Python a lot, which is quite an exception throwing machine in comparison. Still, my code is not cluttered with exception handling. So, converting a ton of warnings to exceptions in PHP does not worry me at all. I would welcome it, but not as a bulk operation. I agree that we need to ask the question for each case. I would still prefer the answers to bias towards exceptions though. Regards, Dik Takken