[Erlang Forums] [Erlang/OTP Proposals/Proposals: RFC] Re-visiting EEP-0055

Loïc Hoguin essen@REDACTED
Fri Apr 29 11:48:38 CEST 2022

On 28/04/2022 14:00, Richard O'Keefe wrote:
> (A) Fix the original problem.  Erlang had a very
>      simple scope rule: the scope of a variable is
>      the *entire* top-level function clause it
>      occurs in.  Reinstate that rule.
>      This is a breaking change, so it needs some
>      sort of -simple_scopes declaration to enable it.
>      We now have a feature declaration that can be
>      used for this.

This is the solution I would prefer with regard to solving locality and 
shadowing. But I am well aware that this would not solve the original 
issue, in particular it wouldn't help avoid accidental matching of 
variables that were already bound. What's at the beginning of the rationale.

There would still need to be a compiler warning/error (should really be 
an error if not already) about exporting variable from case clauses 
where the variable is not defined in all clauses, though, but that's fine.

> (B) Fix the locality problem.  The right way.
>      By declaring which variables are *local*,
>      not which variables are *not* local.
>      Borrowing some syntax from Prolog (as Erlang
>      originally got its syntax thence), let D be
>      a syntactic form made of tuples, lists, and
>      variables, and C be a pattern or expression.
>      Then D ^ C means that each of the variables
>      in D represents a new variable in C, not
>      provided, visible, or in any way accessible
>      in C.

This would also be acceptable but I too would like to see what it would 
look like. I fear that it may end up much more complex to the developer 
than the first solution. Also it probably doesn't solve the original 
issue in the rationale.

Loïc Hoguin

More information about the erlang-questions mailing list