[erlang-questions] preferred looping style

Icarus Alive <>
Wed Jun 22 19:44:00 CEST 2011


Hi,

Of these 2 styles, which one is preferred, and why ?
To me, the readability of 2nd style is better, tough it consumes 1 stack
frame extra.
Are there some cases where style-1 might be preferred, or be the only option
?

%% style-1 -----------------------------------------
mainLoop(InitialRun) ->
 if InitialRun == true ->
   % do some initialization,
   mainLoop(false);
 true ->
   % do routine loop tasks,
   mainLoop(InitialRun)
 end.

%% style-2 -----------------------------------------
loopInit() ->
 % do some intialization,
 mainLoop().

mainLoop() ->
 % do routing loop tasks,
 mainLoop().


cheers,
Icarus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20110622/f4d15072/attachment.html>


More information about the erlang-questions mailing list