Re: New EEP draft: Pinning operator ^ in patterns

Loïc Hoguin <[email protected]>
Newsgroups gmane.comp.lang.erlang.eeps,gmane.comp.lang.erlang.general
Organization Nine Nines
Message-ID <[email protected]>
On 22/01/2021 09:25, Richard Carlsson wrote:
> Den tors 21 jan. 2021 kl 23:55 skrev Loïc Hoguin <[email protected] 
>     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
_______________________________________________
eeps mailing list
[email protected]
http://erlang.org/mailman/listinfo/eeps
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.