[erlang-questions] why isn't scope in "begin end" block?

Dao Gui guidao1013@REDACTED
Sat Oct 10 11:59:23 CEST 2015


Sorry to my pool English
Example:

-module(test).
-export([test/0]).

test() ->
    begin A = 1 end,
    A = 2. %% match error
    %io:format("~p~n", [A]). %normal output

The var A is in begin end scope, but it can visited by other scope.
Why isn't erlang support this?

no this feature, I can't write the next code:
-define(OUTPUT_3(A), begin [_,_,B|_]=A, io:format("~p~n", [B]) end).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151010/07b8aa71/attachment.htm>


More information about the erlang-questions mailing list