[erlang-questions] Style (was eep: multiple patterns)

Richard A. O'Keefe <>
Thu May 29 03:21:35 CEST 2008

On 27 May 2008, at 7:17 am, Darren New wrote:

> Richard A. O'Keefe wrote:
>> I like this because it makes a clean separation between
>> "what are the actions" and "what are the names for the actions".
> Is there anything you'd recommend to someone learning how best to use
> Erlang to get some of these useful idioms?

Apparently this particular one *isn't* an idiom, although I think
it should be.  It's a consequence of a general language-independent

    when your code needs to be structured in two (or more)
    incompatible ways, split it into as many ways, each of
    which can be structured naturally.

and it is vaguely related to the old idea of TABLE-DRIVEN CODE,
as described in Kernighan & Plauger, "The Elements of Programming
Style".  In this case, the function that maps a wild range of
patterns (and guards) to action codes basically is the table
they're talking about.  It's not entirely unrelated to another
old programming idea, which was popularised for COBOL, but did
exist also as an addition to the Burroughs B6700 Algol compiler,
DECISION TABLES, where there is a tabular presentation of a
complex set of decisions about what to do, separated from the
code that performs the actions.

I suppose you could call it the "Decision Table" pattern,
for want of a better name.

More information about the erlang-questions mailing list