Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception filters and pattern matching syntax #2074

Closed
dsaf opened this issue Apr 17, 2015 · 2 comments
Closed

Exception filters and pattern matching syntax #2074

dsaf opened this issue Apr 17, 2015 · 2 comments

Comments

@dsaf
Copy link

dsaf commented Apr 17, 2015

F# treats exception handling as a specialized case of pattern matching:

F# - try:

try
    expression
with
    | pattern -> expression
    | pattern -> expression

F# - match:

match expression
with
    | pattern -> expression
    | pattern -> expression

On the surface it seems like a good idea and made me question whether this was really a good moment to add exception filtering to C# syntax.

C# - try:

try {}
catch (MyException e) when (myfilter(e))
{}

C# - match: ? What options do we have now:

  • try-catch and switch diverge in terms of syntax?
  • expression syntax is created for try-catch as well?

PS: a bit trollish, but has a point - http://tomasp.net/blog/2015/csharp-pattern-matching/index.html

@dsaf dsaf changed the title [Area-Language Design][Discussion] Why add exception filters before pattern matching? [Area-Language Design][Discussion] Exception filters and pattern matching Apr 17, 2015
@dsaf dsaf changed the title [Area-Language Design][Discussion] Exception filters and pattern matching [Area-Language Design][Discussion] Exception filters and pattern matching syntax Apr 17, 2015
@gafter gafter added Area-Language Design Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. Discussion and removed Concept-Determinism The issue involves our ability to support determinism in binaries and PDBs created at build time. labels Apr 17, 2015
@gafter gafter changed the title [Area-Language Design][Discussion] Exception filters and pattern matching syntax Exception filters and pattern matching syntax Apr 17, 2015
@gafter
Copy link
Member

gafter commented Apr 17, 2015

Love that link.

@gafter
Copy link
Member

gafter commented Sep 13, 2015

Closing. We cannot change existing syntax.

@gafter gafter closed this as completed Sep 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants