Re: Resume keyword
| From: | Tjerk Anne Meesters | Date: | Thu, 21 Jun 2012 03:17:21 +0000 |
| Subject: | Re: Resume keyword | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-60909@lists.php.net to get a copy of this message | ||
> 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".
Interesting idea. Just by reading that I thought of this scenario instead:
---------------
try {
echo "about to throw exception";
throw new Exception;
echo "still alive";
} catch (Exception $e) {
resume;
}
-------------
Which kinda looks nice to have. But how about this:
--------------
function my_function()
{
echo "throwing exception";
throw new Exception;
echo "still here?";
}
try {
echo "calling function";
my_function();
} catch (Exception $e) {
resume;
}
----------------
By the time the exception is handled, the function stack would have
been unloaded, so how would it be able to resume? :)
>
> If resume has a value, and the exception was an assignment operation,
> then that value is assigned to the variable.
This feels a bit too magical IMO