New EEP draft: Pinning operator ^ in patterns
Loïc Hoguin
essen@REDACTED
Fri Jan 22 10:10:44 CET 2021
On 22/01/2021 09:25, Richard Carlsson wrote:
> Den tors 21 jan. 2021 kl 23:55 skrev Loïc Hoguin <essen@REDACTED
> You say ^ indicates that the match is intentional, and in a perfect
> world perhaps that's true, but in the real world you'll also end up
> with
> misplaced ^ that should not be matches at all, as some of your examples
> show.
>
>
> Well, those examples had misplaced matches precisely because there was
> no warning and no requirement for the programmer to state exactly what
> they meant. If there had been a warning and a requirement to do
> something (annotation or guard) to silence that warning, the mistake
> wouldn't have made it there in the first place.
I agree, that's why I think an optional warning is a great idea. The
warning could easily be added to a process that would check if new code
introduces a warning, and if it does then the new warnings would be
required to be manually checked for correctness. If the warnings are
correct the process can be updated.
I would trust this far more than the presence of ^ in the code.
This would also be a good opportunity to add a comment for non-obvious
matches.
This kind of process would be a good idea regardless of ^ being
introduced or made mandatory. In that case the check would simply be on
new ^ uses.
--
Loïc Hoguin
https://ninenines.eu
More information about the eeps
mailing list