title: Node.js tail-call optimization: possible or not?
body: <p>I like JavaScript so far, and decided to use Node.js as my engine partly because of <a href="https://stackoverflow.com/questions/3660577/are-any-javascript-engines-tail-call-optimized">this</a>, which claims that Node.js offers TCO. However, when I try to run this (obviously tail-calling) code with Node.js, it causes a stack overflow:</p>
  
  <pre><code>function foo(x) {
      if (x == 1) {
          return 1;
      }
      else {
          return foo(x-1);
      }
  }
  
  foo(100000);
  </code></pre>
  
  <p>Now, I did some digging, and I found <a href="http://dailyjs.com/2013/10/17/yield/" rel="noreferrer">this</a>. Here, it seems to say I should write it like this:</p>
  
  <pre><code>function* foo(x) {
      if (x == 1) {
          return 1;
      }
      else {
          yield foo(x-1);
      }
  }
  
  foo(100000);
  </code></pre>
  
  <p>However, this gives me syntax errors. I've tried various permutations of it, but in all cases, Node.js seems unhappy with <em>something</em>. </p>
  
  <p>Essentially, I'd like to know the following:</p>
  
  <ol>
  <li>Does or doesn't Node.js do TCO?</li>
  <li>How does this magical <code>yield</code> thing work in Node.js?</li>
  </ol>