3 ms·
Which equality will you use if it's not numbers, but something more complicated. What if `(x, y, x)` is matched against some `(a, b, c)` where `a == c`, but no
by Tyr42 6y ago
Which equality will you use if it's not numbers, but something more complicated.
What if `(x, y, x)` is matched against some `(a, b, c)` where `a == c`, but not `a is c`? If yes, and you mutate `x` in the body, does it mutate `a` or does it mutate `c`?
I think at least making it an error now can leave it open to defining it later.
- wool_gather 6y agoThere's certainly no reason to use reference equality. In fact, I think equality is the wrong question: it should duplicate the match. `case (x, y, x)` should `__match__((a, b, c))` IFF `a.__match__(c)` (Not sure if that's exactly the right syntax for the Python calls, but hopefully the idea is clear.) (Elixir has a similar operation to "pin" in a match: if you use an existing variable as the pattern, but pin it, the value must match whatever the variable is already bound to.) > I think at least making it an error now can leave it open to defining it later. Fair point.