[erlang-questions] variable propagation in try
Peti Gömöri
gomoripeti@REDACTED
Wed Jun 17 14:28:04 CEST 2020
(Note for a future self) this limitation will be removed in OTP 24
https://github.com/erlang/otp/pull/2662
On Thu, Jun 28, 2018 at 12:21 PM Richard Carlsson <
carlsson.richard@REDACTED> wrote:
> 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/20200617/7ed34ad7/attachment.htm>
More information about the erlang-questions
mailing list