New EEP draft: Pinning operator ^ in patterns

Eckard Brauer eckard.brauer@REDACTED
Tue Jan 19 13:19:50 CET 2021


Hey, this arises a next question:

> There is nothing in this suggestion that affects the reuse of the same
> variable within a pattern.
> If it's a new variable that's supposed to have the same value in both
> positions, it would look like before: "{X, X} -> ...".
> If it's an already bound variable that occurs twice in the same
> pattern, you'd mark both instances: "{^X, ^X} -> ...".

That means, a "pinned" variable shall have the exact same binding in
each:

* instruction?
* line?
* something else?

Maybe it's the same Erlang shell behaves currently with _X:

 $ erl
Erlang/OTP 23 [erts-11.1.6] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Eshell V11.1.6  (abort with ^G)
<0.81.0> 1> {_X, _X} = {1,2}.
** exception error: no match of right hand side value {1,2}

So, why change?


More information about the erlang-questions mailing list