[erlang-questions] variable propagation in try

Richard Carlsson carlsson.richard@REDACTED
Thu Jun 28 12:21:49 CEST 2018


If I recall correctly, it was initially decided to keep the set of safe
variables conservative when try/catch was added. It could be relaxed to
allow this case.


        /Richard

2018-06-28 12:08 GMT+02:00 Peti Gömöri <gomoripeti@REDACTED>:

> Hello,
>
> I understand that passing variables between different blocks of a try
> catch expression is mostly unsafe, because in case of expressions it is not
> guaranteed that the variable binding actually happened.
>
> But why using a variable in a clause after "of" that is bound in the block
> after "try" is marked as unsafe by the compiler?
> For example:
>
> ```
> f() ->
>     try
>         {A, B} = a:b(),
>         A
>     of
>         ok ->
>             B %% unsafe ???
>     catch _:_ ->
>             a:b()
>     end.
> ```
>
> thanks
> Peter
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180628/43b17ae2/attachment.htm>


More information about the erlang-questions mailing list