I'm very well aware of the fact that catching 'Exception' has the same effect, but why require it when you don't care? Specifying a type indicates that you do want a specific type (alright, the least specific one, but not all people may know, especially Java people who have Throwable as superclass of Exception), where you don't actually need one.


Leaving of the variable can help in finding unused variables. IDE's have excellent static analysis tools and will tell you about unused variables, so avoiding them in catch-statements when not used helps in making the analysis more robust.

On 24 juni 2013 at 15:32:04, Sherif Ramadan ([email protected]) wrote:




On Mon, Jun 24, 2013 at 9:23 AM, Joost Koehoorn <[email protected]> wrote:

For instance, a library may throw an exception if some condition is not met, and you just try to call the method to see if it works, because you may not know the exact conditions (and these conditions may change). By allowing for an anonymous catch block there, you indicate that you really don't need to know anything about the exception, just that you'd like to recover from it.


Phil's request was a little different, he asked for making the variable optional. I added support for both, but surely it can be decided that only the unnamed-catch is implemented.


Both options are possible in C#.


I don't think you've dug into PHP's implementation of Exceptions enough to realize the useful (or lack thereof) of this proposal, because if you have you would realize that all Exceptions in PHP are extended by a single type "Exception", and thus it is already possible to catch any Exception without this implementation.

As for making the variable optional, I don't see much point. You can simply ignore it in your catch block if you want.

I'm not saying you shouldn't take the time to look into it further and propose an actual RFC (you might have some valid technical use case), but I am saying you certainly haven't presented one yet. 
-- 
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to