Culture shock

Josh Snyder <>
Sat Dec 2 02:34:52 CET 2000


I'm a newcomer to Erlang and functional programming as a whole. I have a
question about how you keep the flow of control readable.

It appears that for each potentially unbounded loop, the Erlang program
is forced into calling a new function and then immediately ending for
tail recursion.  This prevents me from using my usual imperative
language structure.  One in which you can see the entire program
structure by analyzing the sub-procedure names in a "main function".

A recommendation in the Erlang style guide is to use functions in place
of if's and case's when nested conditionals start edging the code to far
to the right.  When replacing nested for's, if's, and case's with tail
recursive functions, the usual start and loop or init and loop functions
just don't cut it.

Tail recursion looks uncannily like the infamous goto statements, where
calling functions comes to look a lot like jumping around labels.  How
do you keep the pasta out of Erlang code?

                        -Josh

-------------
Joshua J. D. Snyder





More information about the erlang-questions mailing list