[erlang-questions] is empty catch statement possible?

Motiejus Jakštys desired.mta@REDACTED
Fri Feb 10 09:09:54 CET 2012


2012/2/10 Konstantin Tcepliaev <f355@REDACTED>:
> Hello again, Motiejus.
>
> One more thing: macro variables' scope is not limited to the text of macro, so in a piece of code such as:
>
> lager:set_loglevel(lager_console_backend, InitialLevel),
> ..
> ?silent(SLevel, Expr),
> ..
> lager:set_loglevel(lager_console_backend, NewLevel), %% NewLevel /= InitialLevel
> ..
> ?silent(SLevel, OtherExpr), %% badmatch here!
>
> ..you'll get a badmatch error on your __Lager_OldLevel variable. Redefining your macro as a normal function would be a great solution.

This is why I was initially wrapping the macro to the function.
"JavaScript"ish way makes sense in this case, so Lager_OldLevel will
be in a separate scope.

-- 
Motiejus Jakštys



More information about the erlang-questions mailing list