[erlang-questions] Warning not emitted on string matching clauses

Fred Hebert <>
Wed Apr 1 20:57:47 CEST 2015


On 04/01, Pierre Fenoll wrote:
>Ferd on IRC mentioned that the compiler might feel free to reorder 
>clauses.

The compiler would only reorder clauses that are free to do so.

For example:

    f(a) -> 1;
    f(b) -> 2;
    f(X) when is_atom(X) -> 3;
    f([_|_]) -> 4;
    f({_}) -> 5.

Would let the compiler possibly reorder 1 & 2, and maybe 4 & 5. But the 
presence of a guard clause or ambiguous matches would prevent it from 
doing more than that, if my understanding is accurate.


More information about the erlang-questions mailing list