Skip to content

Commit d55c3d8

Browse files
committed
Reword a couple sentences in catch clause proposal
1 parent 38afb27 commit d55c3d8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

proposals/NNNN-multi-pattern-and-conditionally-compiled-catches.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ do {
2727
TaskError.anotherFailure(let msg) { // Not currently valid
2828
showMessage(msg)
2929
}
30-
3130
```
3231

3332
Because the above snippet is not valid today, developers frequently end up duplicating code between catch clauses, or writing something like the following instead:
@@ -46,7 +45,7 @@ do {
4645
}
4746
```
4847

49-
Nesting the switch inside of the catch clause is awkward and introduces additional nesting. It also defeats the purpose of supporting pattern matching in catch clauses. Splitting the code up into multiple catch clauses requires duplication, which is also undesirable. Supporting a multi-pattern catch clause would allow for code which is both clearer and more concise.
48+
Nesting the switch inside of the catch clause is awkward and defeats the purpose of supporting pattern matching in catch clauses. Splitting the code up into multiple catch clauses requires duplicating the body, which is also undesirable. Supporting a multi-pattern catch clause would allow for code which is both clearer and more concise.
5049

5150
The following use of `#if` is also not allowed today and frequently leads to nesting of switch statements inside catch clauses:
5251

@@ -62,13 +61,11 @@ catch TaskError.macOSOnlyError {
6261
catch {
6362
crossPlatformRecovery()
6463
}
65-
6664
```
6765

68-
6966
## Proposed solution
7067

71-
Catch clauses should allow the user to specify a comma-separated list of patterns. If an error thrown at runtime in a do block matches any of the patterns in a corresponding catch clause, that catch clause should be executed. Similar to switch cases, a user should be able to bind a variable in all patterns of a catch clause and then use it in the body.
68+
Catch clauses should allow the user to specify a comma-separated list of patterns. If an error thrown at runtime in a do block matches any of the patterns in a corresponding catch clause, that catch clause's body should be executed. Similar to switch cases, a user should be able to bind a variable in all patterns of a catch clause and then use it in the body.
7269

7370
Additionally, conditional compilation directives should be permitted to appear surrounding catch clauses.
7471

0 commit comments

Comments
 (0)