On Tue, Jun 17, 2014 at 12:36 PM, C. Scott Ananian <[email protected]>
wrote:
> My guess would be that `catch` is reserved so that (in a future
> version of JavaScript) this won't be ambiguous:
> ```
> try { stuff(); }
> catch(e1) { }
> catch(e2) { }
> ```
>
> Currently JS only allows a single catch clause.
FWIW: some implementations (e.g. SpiderMonkey) has this approach for years,
using guards:
try { throw 1; }
catch (e if (e instanceof TypeError)) { console.log(e); }
catch (e) { console.log('Generic handler:', e); }
Dmitry
> But if it ever grows
> guarded catch expressions, then you would want to add multiple catch
> clauses. All but the first could potentially be ambiguous with an
> invocation of a function named `catch`.
> --scott
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss