alpaca
alpaca copied to clipboard
Reuse variable in pattern matches for equality
In Erlang we can do the following to express two tuple items that are equal:
case Tuple of
{X, X} -> ...
end
In Alpaca we currently have to do this:
match tuple with
(x, y), x == y -> ...
I'd much prefer for us to be able to be like Erlang here:
match tuple with
(x, x) -> ...
The latter seems like a more expressive form to me. This should be relatively simple to solve in the AST generation stage by rewriting multiple occurrences of a symbol in a pattern to a sequence of synthesized names and some added equality guards.
@rvirding, can you chime in here re: why LFE does it the same way as Alpaca currently does?
Just felt that the implicit equality testing felt more logic than functional. It also mapped more directly onto core erlang :-). I am not that fixed on it.