[erlang-questions] case expression scope

Thomas Lindgren thomasl_erlang@REDACTED
Wed Mar 5 16:38:21 CET 2014


Occurrences of bound variables in patterns. For example A, B, C, and D in these:

  {A, B} = f(X),
  {A, B} = f(Y),   % A,B already bound
  C = g(Z),
  C = g(W),        % C is already bound
  {D,D} = h(V)     % D is bound then matched

Best,
Thomas




On Wednesday, March 5, 2014 3:39 PM, Anthony Ramine <n.oxyde@REDACTED> wrote:
 
What would you like to be warned about? I don’t get it.
>
>-- 
>Anthony Ramine
>
>
>Le 5 mars 2014 à 15:33, Thomas Lindgren <thomasl_erlang@REDACTED> a écrit :
>
>> Thanks Anthony, that option warns for Value in the previous example because it's exported from the case, but not for the variable match that then occurs. I'd like to see a compiler option that warned about matching (bound variables occurring in patterns), which would catch other inadvertent reuse of variable names.
>> 
>> Best,
>> Thomas
>> 
>> 
>> On Wednesday, March 5, 2014 2:40 PM, Anthony Ramine <n.oxyde@REDACTED> wrote:
>> The compile option is warn_export_vars:
>> 
>>     Causes warnings to be emitted for all implicitly exported variables referred to after the primitives where they were first defined. No warnings for exported variables unless they are referred to in some pattern, which is the default, can be selected by the option nowarn_export_vars.
>> 
>> -- 
>> Anthony Ramine
>> 
>> Le 5 mars 2014 à 12:18, Thomas Lindgren <thomasl_erlang@REDACTED> a écrit :
>> 
>> > In the larger scheme of things: The way I see it, the feature of implicit variable matching is more trouble than it's worth. Warnings about such matches would catch this kind of problems.
>> > 
>> 
>> 
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140305/6d981bb3/attachment.htm>


More information about the erlang-questions mailing list