<div dir="ltr">The difference is implicit vs explicit. When it is explicit compiler assumes you are aware of what you are doing and you control the return value of each case clause.<div><br></div><div>Theepan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 29, 2015 at 1:36 PM, Martin Koroudjiev <span dir="ltr"><<a href="mailto:mrtndimitrov@gmail.com" target="_blank">mrtndimitrov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I am confused why this code generates warning with the warn_export_vars<br>
option:<br>
<br>
-module(test).<br>
<br>
-export([test/1]).<br>
<br>
test(Mode) -><br>
    case Mode of<br>
        r -> {ok, FP} = file:open("warn.erl", [read]);<br>
        w -> {ok, FP} = file:open("warn.erl", [write])<br>
    end,<br>
    file:close(FP).<br>
<br>
compile:file("test.erl", [report, warn_export_vars]).<br>
test.erl:10: Warning: variable 'FP' exported from 'case' (line 6)<br>
{ok,test}<br>
<br>
Why this is better than this code:<br>
<br>
test(Mode) -><br>
    {ok, FP} =<br>
        case Mode of<br>
            r -> file:open("warn.erl", [read]);<br>
            w -> file:open("warn.erl", [write])<br>
        end,<br>
    file:close(FP).<br>
<br>
which produces no warnings?<br>
<br>
Thanks in advance.<br>
<br>
Regards,<br>
Martin<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div>