[erlang-questions] Local namespaces in case/try

Jeremey Barrett jbarrett@REDACTED
Tue Jul 10 17:55:34 CEST 2012


Hi all, +1 for real let. 

However, you can do something like this:

  -define(lets(C), begin fun() -> C end() end).

  Val1 = ?lets(case do_something() of
                   {ok, Result} -> Result;
                   {error, Error} -> Error
               end).

  Val2 = ?lets(case do_another() of
                   {ok, Result} -> Result;
                   {error, Error} -> Error
               end).

Only Val1 and Val2 are bound outside the macro calls.

Regards,
Jeremey.

On Jul 10, 2012, at 5:19 AM, Dmitrii Dimandt wrote:

> Val1 = case do_something() of
>                {ok, Result} -> Result;
>                {error, Error} -> Error
>            end,
> Val2 = case do_another() of
>                {ok, Result} -> Result;
>                {error, Error} -> Error
>            end,




More information about the erlang-questions mailing list