[erlang-questions] [clarify] Variable binding in case clause and coding style

Christian S chsu79@REDACTED
Mon Mar 10 13:21:36 CET 2008


>  case Endianness of
>   big-> <<A:1/unit:32-big, Rest/binary>>;
>   little-> <<A:1/unit:32-little, Rest/binary>>
>  end,
>  do_something(A,Rest).

I rather rewrite it to this:

case Endianness of
  big ->
    <<A:1/unit:32-big, Rest/binary>>,
    do_something(A,Rest);
  little ->
    <<A:1/unit:32-little, Rest/binary>>,
    do_something(A,Rest)
end.

It is simply easier to understand and not misinterpret.  Lexical
scoping for teh win.



More information about the erlang-questions mailing list