Re: [RFC] New in initializers

From: Date: Thu, 17 Jun 2021 09:31:46 +0000
Subject: Re: [RFC] New in initializers
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-114921@lists.php.net to get a copy of this message
> On Jun 17, 2021, at 5:14 AM, Nicolas Grekas <nicolas.grekas+php@gmail.com> wrote:
> 
> Le mer. 16 juin 2021 à 13:47, Larry Garfield <larry@garfieldtech.com> a
> écrit :
>> Would others be comfortable with that, if it allowed new-initializers for
>> static properties and class constants?
>> 
> 
> Honestly, I don't know.
> 
> Instantiation might fail because of either a throwing constructor or
> because of a throwing autoloader.
> 
> Being able to know where to put the try/catch to recover from these might
> be important when writing generic code.
> 

> With the current state of the RFC, it's fine. With "undefined evaluation
> time", it might make things fragile without any way to make them resilient
> enough.

Wouldn't the simple way to make them resilient enough be to wrap a try-catch block around any
code that potentially throws an exception within the class being instantiated on initialization?

-Mike


Thread (38 messages)

« previous php.internals (#114921) next »