Analyze the syntax choices with typed exceptions and exception filters. Find the strengths and weaknesses of both and whether they conflict in a breaking way that prohibits adding exception filters at a later time outside of this specification.
In C# they use a when keyword to add filtering. If someone wants to breakdown what every other language allows or alternatives this would help a lot. It's not important which syntax is chosen, but what is important is ensuring that this specification doesn't conflict with future specifications.
For example the following syntax can be added later without conflicting:
This introduces a new keyword though and it's possible future proposals with new keywords would be scoffed at for adding complexity. I'm not even sure TC39 would agree to adding something that could be written with an if statement so exception filters if they are implemented would probably have to have clear strengths.
At the very least I want to include a future consideration section with various proposed exception filtering proposals to show it doesn't conflict. I've had two people mention them off hand, but I haven't gotten any clarification to what their worry was. It might seem naive, but the goal is that anyone can read the spec and feel confident that their worries have been addressed.
Possible syntax:
catch (e:TypeError, e => e.example == `foo`)
Lastly weird syntax, and not that much more compact:
catch (e:TypeError => e.example == `foo`)
This last one is weird because the catch would be expected to extract the first parameter from the arrow function. These have the advantage though that they don't introduce a new keyword which makes them more likely to be considered though.
Analyze the syntax choices with typed exceptions and exception filters. Find the strengths and weaknesses of both and whether they conflict in a breaking way that prohibits adding exception filters at a later time outside of this specification.
Refer to C#: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/try-catch
A simple typed exception is:
In C# they use a when keyword to add filtering. If someone wants to breakdown what every other language allows or alternatives this would help a lot. It's not important which syntax is chosen, but what is important is ensuring that this specification doesn't conflict with future specifications.
For example the following syntax can be added later without conflicting:
This introduces a new keyword though and it's possible future proposals with new keywords would be scoffed at for adding complexity. I'm not even sure TC39 would agree to adding something that could be written with an if statement so exception filters if they are implemented would probably have to have clear strengths.
At the very least I want to include a future consideration section with various proposed exception filtering proposals to show it doesn't conflict. I've had two people mention them off hand, but I haven't gotten any clarification to what their worry was. It might seem naive, but the goal is that anyone can read the spec and feel confident that their worries have been addressed.
Possible syntax:
Lastly weird syntax, and not that much more compact:
This last one is weird because the catch would be expected to extract the first parameter from the arrow function. These have the advantage though that they don't introduce a new keyword which makes them more likely to be considered though.