Re: New EEP draft: Pinning operator ^ in patterns

Mikael Pettersson <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CAM43=SNEC_7tGdVaBz-+7tXbXiYKn8cWRraX2XzXEh83Wv6LUw@mail.gmail.com>
On Fri, Jan 15, 2021 at 4:36 PM Raimo Niskanen
<[email protected]> wrote:
> And I want to get clarity about exactly why so many developers are worried
> about this particular proposed change, and therefore try to look thoroughly
> at the arguments.
>
> It is as you say a fundamental detail in the language.
>
> 1) Would the language be a better language with a mandatory pinning operator?
>
> 2) If so is there a migration path worth the trouble?
>
> So far I think the discussion has been centered around 2),
> before talking about 1).

I acknowledge the issue the pinning operator is trying to solve, but I
disagree with the solution, especially the syntactic noise and
special-case semantics of the operator.

I believe that a better solution is to gradually abolish the notion
that variables in patterns may refer to the surrounding scope. This
means adding "when PatVar = OtherVar" guards in the few affected
places, but those guards are already part of the language, and already
required in some contexts. That is, nothing needs to be _added_ to the
language, instead the language is simplified by having fewer special
cases in its semantics.

Migration would be a straight-forward sequence of steps mainly adding
a warning option to the compiler, at some point enabling it by
default, and eventually making it mandatory.

One issue is that the compiler _must_ still recognize the ref trick in
selective receives when expressed using "when PatVar = OtherVar"
guards. (This may or may not already be the case.)

/Mikael
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.