Re: Re: Are exceptions allowed in php core?
| From: | Rasmus Lerdorf | Date: | Sun, 02 Sep 2012 01:07:12 +0000 |
| Subject: | Re: Re: Are exceptions allowed in php core? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-62646@lists.php.net to get a copy of this message | ||
On 09/01/2012 05:44 PM, Gustavo Lopes wrote:
> More importantly, there is no other satisfactory solution (except a
> fatal error). foreach has no return value, so it has no other way to
> signal a failure. If we used a notice or a warning here what would
> happen is that code that used generators with an invalid state would,
> except for the notice, work as if it had been given an empty iterator.
> Put another way, it would fail with only a notice, and continue. That is
> a far more serious problem. In other circumstances where we emit
> warnings, we usually have a return value the caller can check for error
> conditions.
This is the real question here. It actually isn't about Exceptions at
all. It is whether trying to iterate a closed generator should be a
fatal error that breaks script execution right then and there. Whether
that is done as an exception or a fatal error isn't actually all that
relevant since the end result will be the same for most people. If
everyone is in agreement that this should be a fatal error (I don't
personally get why it has to be fatal) then lets just make it a fatal
error and when we come up with a decent proposal for turning recoverable
fatals into exceptions language-wide we can revisit this. And this might
even be in the same release, so...
-Rasmus