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

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to