Re: New EEP draft: Pinning operator ^ in patterns

"Michael P." <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <20210128153532.22c68e2c@aesop>
On Wed, 27 Jan 2021 23:04:54 +0100
Raimo Niskanen <[email protected]> wrote:

> So have no fear, the pinning operator would not take away any feature from
> Erlang.  Hopefully it would give clarification to newcomers; when I first

Sorry, but yes it would: its simplicity!


> learned Erlang I missed some way to see the difference between binding a
> variable in a pattern and using an already bound variable.

Is that not only the case with the match operator?

Do not all other patterns intoduce a new scope?

And friend compiler already warns about any attempt
at closure therein?

The Erlang doc says:

a) "A pattern has the same structure as a term but
    can contain unbound variables."

b) "A variable is an expression."

c) "An arithmetic expression can be used within a pattern [...]
    can be evaluated to a constant when complied."

Now:

a) is incomplete, it can also contain boundies and thus, see b),
a type of expression that contradicts c).

I would not want to add any explanation of a syntactical
annotation to that. Not even after a cleanup, as this shows
that it is already complicated enough.

If it wasn't Erlang, I would run and hide -- and I _could_ hide ...


> The pinning operator would make this distinction clear, in precisely
> the spot where the already bound variable is used in a pattern, which is
> the odd case that deserves highlighting.

I am working on the examples but for now: does it not simply
_hide_ a need to rephrase to explicitness?

By the way: Is it an operator in Elixr? If not, I would quickly
retreat two steps from anything and anyone having to do with Elixir.

~M

--

¡Menos economia! - ¡Mas econotuya!

Less economy! - More econoyou!
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.