[erlang-questions] why isn't scope in "begin end" block?
Brujo Benavides
fernando.benavides@REDACTED
Sat Oct 10 14:45:42 CEST 2015
You can’t write that but you can write this:
output_3(A) -> [_,_,B|_]=A, io:format(“~p~n”, [B]).
and then, in your code, instead of ?OUTPUT_3(…something…) you just use output_3(…something…)
> On Oct 10, 2015, at 06:59, Dao Gui <guidao1013@REDACTED> wrote:
>
> 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).
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list