[erlang-questions] Function Declaration Syntax
James Hague
james.hague@REDACTED
Mon May 16 16:49:21 CEST 2011
On Sat, May 14, 2011 at 6:34 AM, Torben Hoffmann
<torben.lehoff@REDACTED> wrote:
> This is - in my book - a step backwards.
> You should haev the spec for the function and then pattern matching in the
> function clauses since it gives you:
>
> Overview of what the function does.
> 1st level overview of how the function branches out.
>
> This makes debugging so much faster than having to get inside a function
> only to meet a case on the parameters as the first thing.
My personal style:
I keep everything in the function header if there are only a couple of
parameters.
If there are, say, four parameters to a function and only the first
one is used for pattern matching, then I use "case." That makes it
clear at a glance which parameters matter for matching and which are
fixed.
James
More information about the erlang-questions
mailing list