Pre-SIP: better strictEquality support in pattern matching

Hey there, Happy German Unity Day (October 3rd) to everybody.

I’ve written a SIP draft on how to improve pattern matching to make it more practical in code bases compiled with the strictEquality feature.

I’ve worked on multiple projects where I would have liked to enable strictEquality for the improved type safety that it provides, but without exception, this failed due to compilation errors for basic ADT pattern matching.
It’s time to fix it and I welcome any constructive feedback.

5 Likes

I suggest you add links to previous discussions:

3 Likes

Thanks @soronpo, I’ve added links to related discussions (including this thread) in the Related Work section of the SIP draft.

I’d like a bit more discussion on the differences between changing the desugarring to _ : MyObject.type and not requiring the Equals instance

(I don’t have any opinions on the matter, but it should be presented in the SIP)

1 Like

Thanks @Sporarum, I’ve added a paragraph in the Alternatives section explaining the pros and cons of this approach. tldr: benefits of the type check behaviour are marginal, backward compat matters more. But please feel free to point out any benefits (or drawbacks) that I may have missed.

1 Like

Perfect, that’s what I would have expected as well, so not I can’t think of anything else ^^

2 Likes

Since there have been no further comments for the past two weeks, I’ve decided to submit this to the committee.
Thanks to everyone for participating.

2 Likes