I can't get this out of my head after two weeks, but some part of me
says this is a *really* bad idea.  Of course another part of my brain
things its a great idea and I'm getting tired of the argument.

Resume is similar to return, but can only be used in catch blocks or
in error handling functions.  When encountered the run time returns to
the line after the exception was initially thrown and, well,
"resumes".

If resume has a value, and the exception was an assignment operation,
then that value is assigned to the variable.

The part of me that likes this idea points out it allows exceptions to
behave like PHP errors when that behavior is wanted.  It would also
open the possibility of converting all engine errors to exceptions,
because a mechanism would now be in place to handle exceptions in BC
manner to errors would be in place. Further, the default exception
handler could call resume after echoing on the non fatal errors.

The part of me that hates this idea is concerned with how it could be
abused to create even more nightmarish spaghetti tangles.

An example for additional clarity.

set_exception_handler(function ($e) {
  echo $e->getMessage();
  // Don't know if this is correct - but should be able to illustrate here
  if ($e->getCode() == E_NOTICE & E_STRICT) {
    resume null;
  }

  echo 'Dying now'; exit;
});

throw new Exception('A test', E_NOTICE);

echo "We didn't die";

The code above when run would echo "A test. We didn't die.";

I leave this to smarter people than me.

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

Reply via email to