[erlang-questions] Pattern matching in function calls
Dave Challis
dsc@REDACTED
Wed Apr 13 13:44:50 CEST 2011
Does the order of patterns in a function call matter? Are they all
tested, or will erlang stop trying to match them once a mismatch has
been found?
As an example, if I've got:
foo(<<SomeLargeBinary>>, a) -> a;
foo(<<SomeLargeBinary>>, b) -> b.
will the above be any slower than defining:
foo(a, <<SomeLargeBinary>>) -> a;
foo(b, <<SomeLargeBinary>>) -> b.
Will the <<SomeLargeBinary>> attempt to be matched in every case? Is it
something worth thinking about, or will the compiler optimise this?
Thanks,
--
Dave Challis
dsc@REDACTED
More information about the erlang-questions
mailing list