New EEP draft: Pinning operator ^ in patterns

Michael P. empro2@REDACTED
Thu Jan 28 23:31:48 CET 2021


:-)

On Thu, 28 Jan 2021 16:13:39 +0100
Richard Carlsson <carlsson.richard@REDACTED> wrote:

> Den tors 28 jan. 2021 kl 15:38 skrev Coconut <c0c0nut@REDACTED>:

> 1) every code snippet that contained the pinning operator have seemed odd or confusing to me, but I may have misunderstood the proposal or the pinning operator. If this is going

That is about how I am feeling for about a week now.
Are you not afraid such annotation would only help
hide problematic code?


> without a change like it (such as moving away completely from already-bound
> variables in patterns, using guards only instead), I don't see many ways to

Can you show how one uses a guard in a match-operation (`=`)?
Why has EEP 55 nothing on the match-operator?


> changing other scoping rules either, in either direction, in a way that
> preserves compatibility. That in turn limits a lot of other things.

Scoping is easy:

Every pattern, apart from LHS `=`, opens a new scope.

Every symbol in the surrounding scope is available via
closure in both guards and body.

The compiler warns about symbols in the pattern that equal symbols
in the surrounding scope and thus prevent closing over them:
your decision. (I've found that I did not use `-Werror` with the compiler,
but with my brain; I remove these "shadowings".)

Next I will try to convince myself with some of the examples
you've dug up (only a bit too late :-)

~M

--

Car and cider give me a pleasant mediterranean
feeling, whereas cdr makes me shudder.





More information about the erlang-questions mailing list