New EEP draft: Pinning operator ^ in patterns
Wed Jan 20 21:15:46 CET 2021
Den ons 20 jan. 2021 kl 14:58 skrev Nalin Ranjan <ranjanified@REDACTED>:
> As I could have a name whose first occurrence happens to be on line number
> 100, and all subsequent occurrences annotated with ^ in a defensive style.
> So far so good.Tomorrow I could embark on "Refactoring" fleet, and add some
> new code to the function around line 30-50, and endup naming one of my new
> variables to be the same as the one on line number 100. Situation,
> re-emerged. I need to go and attend these variables to deal with the
The whole point of the annotations is that previously, if you did what you
described, your new code would be accepted without a word from the
compiler, but would crash on line 100 when the previous first assignment
has turned into an equality assertion. With this EEP and the warnings
enabled, the compiler would tell you that your code on line 100 is now an
unannotated use of a variable bound around line 30. You would have to
change your code, yes, but you would have had to do so anyway because it
was broken. The only question is whether you'd like to know about this at
compile time or later in testing or in production.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions