I was just talking with a co-worker today about why it's ok for 'catch' to be a property name, but not a variable identifier. It's clear that the reasoning here is because property names aren't restricted by reserved words, but it's unclear why 'catch' must be reserved to begin with?

I had always assumed that keywords are reserved for syntax ambiguity reasons...but when I think about it I can't come up with any scenarios where a hypothetical 'catch' variable could be ambiguous with a catch block... What am I missing?

Since try blocks must always be followed by either a catch-block, a finally-block, or catch-then-finally it seems it's always easily possible to distinguish a catch block from a function-call + empty-block:
```
// Never an ASI concern because try is followed by catch
try { stuff(); }
catch(e) {}
```

```
// Not valid, so it's not possible to confuse this with try-finally + call + empty block
try { stuff(); }
finally { }
catch (e) {}
```

-Jeff
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to