Align catch with switch syntax #2809
Unanswered
Andrew-Hanlon
asked this question in
Language Ideas
Replies: 2 comments
-
I don't see how this proposal concerning writing exception handlers is in any way related to 2568 which is about XML docs. |
Beta Was this translation helpful? Give feedback.
0 replies
-
@Joe4evr Sorry typo in issue number. Corrected. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The existing catch block is already patterny with type handling and
when
conditions.It would be great if the catch block had alignment with the switch expression and statement syntaxes.
Example of a few proposed syntaxes:
This would be an addition, not a change - and I believe would not have any issue with backward compatibility or interoperability with the existing syntax.
Importantly in both syntaxes the block contents (each case) would be equivalent to writing a set of
catch(ExType ex) when (condition) {...}
blocks. Thereby, if the default case is omitted, then standard catch fall-through is followed.While there is zero criticality to this proposal, it would nicely unify the language syntax - and IMHO looks sleek.
(One half of this proposal was raised already in #2688)
Beta Was this translation helpful? Give feedback.
All reactions