[erlang-questions] flash clauses vs nested clauses

Pablo Platt pablo.platt@REDACTED
Thu Apr 5 17:22:59 CEST 2012


Hi,

Is there a difference in performance between using nested clauses and flat clauses
or is the compiler smart enough to produce the same optimizations?

For example:

somefun(a1, b1, c1) ->
    res1;
somefun(a1, b1, c2) ->
    res2;
somefun(a1, b1, c3) ->
    res3;
somefun(a1, b2, c1) ->
    res4;
somefun(a1, b2, c2) ->
    res5;
somefun(a2, b1, c1) ->
    res6;
somefun(a2, b1, c2) ->
    res7;
...
somefun(a10, b10, c10) ->
    res10.


and

somefun(a1, B, C) ->
    case B of
        b1 ->
            case C of
                c1 -> res1;

                c2 -> res2;

                c3 -> res3

            end;
        b2 ->
            case C of
                C1 -> res4;

                C2 -> res5
            end

     end;
somefun(a2, B, C) ->
    ...

Thanks




More information about the erlang-questions mailing list