If you are concerning yourself about 1 stack frame extra, you're using the wrong language. Style 2 is definitely the way to go.<br><br><br>Sergej<br><br><div class="gmail_quote">On Wed, Jun 22, 2011 at 7:44 PM, Icarus Alive <span dir="ltr"><<a href="mailto:icarus.alive@gmail.com">icarus.alive@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br><br>Of these 2 styles, which one is preferred, and why ?<br>To me, the readability of 2nd style is better, tough it consumes 1 stack frame extra.<br>
Are there some cases where style-1 might be preferred, or be the only option ?<br>
<br><span style="font-family:courier new,monospace">%% style-1 -----------------------------------------</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">mainLoop(InitialRun) -></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  if InitialRun == true -></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    % do some initialization,</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    mainLoop(false);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  true -></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    % do routine loop tasks,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    mainLoop(InitialRun)</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  end.</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"></span><span style="font-family:courier new,monospace">%% style-2 -----------------------------------------</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">loopInit() -></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  % do some intialization,</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  mainLoop().</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">mainLoop() -></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">  % do routing loop tasks,</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  mainLoop().</span><br><br><br>cheers,<br><font color="#888888">
Icarus
</font><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>