<div dir="ltr"><div>In the doc page you linked:<br>> If the last expression of a function body is a function call,
      a <strong>tail recursive</strong> call is done.<br><br></div><div>Compiler will replace call opcode with a tail call (call_last, call_ext_last, apply_last). You can check it with "erl -S test.erl" to see assembly, and in erl console: "l(modulename)." to load the module then "erts_debug:df(modulename)." to create disassembly from BEAM VM memory (it will be a bit different from the erl -S output).<br><br></div><div>See that your calls are replaced with one of: call_last, call_ext_last, apply_last.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-10-17 10:58 GMT+02:00 Salikhov Dinislam <span dir="ltr"><<a href="mailto:Dinislam.Salikhov@kaspersky.com" target="_blank">Dinislam.Salikhov@kaspersky.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div class="m_-6524208612865981557moz-text-flowed" style="font-family:-moz-fixed;font-size:12px" lang="x-unicode">Hello.
      <br>
      <br>
      Erlang guarantees tail recursion optimization and states it in the
      documentation:
      <br>
      <a class="m_-6524208612865981557moz-txt-link-freetext" href="http://erlang.org/doc/reference_manual/functions.html#id78464" target="_blank">http://erlang.org/doc/<wbr>reference_manual/functions.<wbr>html#id78464</a>
      <br>
      <br>
      Does erlang guarantee that tail call optimization is done in a
      generic case, without recursion?
      <br>
      Say, we have a function calling a function from another module as
      its final statement:
      <br>
          alpha() ->
      <br>
              xxx:beta().
      <br>
      Is it guaranteed that xxx:beta() will use the stack of alpha()
      regardless whether recursion is involved.
      <br>
      I mean whether the language guarantees it rather than virtual
      machine may provide such optimization.
      <br>
      <br>
      Thanks in advance,
      <br>
      Salikhov Dinislam
      <br>
    </div>
  </div>

<br>______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>