On 20.07.2012, at 12:33, Ivan Enderlin @ Hoa wrote: > Making braces optional for try/catch does: > + not break backward compatibility; > + add consistency in the PHP syntax; > ± offer a new way to write buggy programs but no more than with other control > structures (think about goto ;-)). > > I see more + than - here. Am I wrong?
You are not wrong. This is the inconsistency and it makes sense to fix it. We are definitely not going to "unfix" it for if/else, so I "+1" your proposal in advance > Moreover, in parallel, a new idea has been landing: introducing the “rescue” > keyword as a shortcut/replacement of try/catch, such as: > $foo = callThatCouldThrow() rescue 'oof'; > Is it possible to chain it, such as: > $foo = callThatCouldThrow() rescue anotherCallThatCouldThrow() rescue 'oof?'; > > Maybe we should start another topic because it could be a nice idea. I don't see value in this. "finally" would be much more valuable. try { doSomething(); } catch (\Exception $e) { handleException(); } finally { genericCleanup() // called if everything is good, if everything is bad or even if exception is rethrown }
signature.asc
Description: Message signed with OpenPGP using GPGMail