alavrik/erlson — Issue #3: Pattern matching support
Author: gleber
Created: 2012-01-13 10:10:50+00:00
State: open

I was wondering if it is possible to implement the simple pattern matching cases like:

case X of
#{a = A, b = B} -> true
#{a = A, b = 42, c = C} -> false
end

introducing some artificial variables at compile time:

_TMP36 = X.a,
_TMP95 = X.b,
_TMP28 = X.c,
case {_TMP36, _TMP95, _TMP28} of
{A, B, _} -> true
{A, 42, C} -> false
end

This would be much more complicated if we want to implement pattern matching for function clauses and more complex cases. But even such implementation would be a small step forward.

Anton, what's your opinion on this?