New EEP draft: Pinning operator ^ in patterns

Attila Rajmund Nohl attila.r.nohl@REDACTED
Fri Jan 22 21:42:34 CET 2021


Kostis Sagonas <kostis@REDACTED> ezt írta (időpont: 2021. jan. 21., Cs, 1:10):
[...]
>    Should this warning pass be introduced?
>
> My view is YES.  This pass can certainly be useful to many developers
> and I also bet it will detect real bugs in existing code bases.  So YES
> with all capital.

Just today I almost wrote some code that could have triggered a
warning like this. During writing code, code is moved around (need to
extract some code into a function or just used as a template, etc.) -
if a value is represented by a certain variable name, I tend to use
the same variable name in other functions in the same module to ease
reasoning about. If code is moved around in the editor, there's a
chance that it ends up in a place where that variable is already
assigned. Actually I noticed that even before I saved the source file
as the function was small, but sometimes I do miss stuff like this. So
I'd really like this warning.

> But IMO, we do not need strange hieroglyphics (with ad hoc design, as I
> explained above) to shut off these warnings.  Plain `when` clauses with
> =:= tests suffice for this -- perhaps with the exception of pattern
> matching with variables used as lengths of bitstring segments where the
> compiler warning pass can simply be silenced / not check.

I also do agree with this. I understand that a "when Value =:= V"
might be too verbose, but it's explicit.


More information about the erlang-questions mailing list