title: Avoiding 'too much recursion' error
body: <p>Basically what I'm trying to do boils down to</p>
  
  <pre><code>function a() {
      // Do stuff that waits for things etc
      b(a);
  }
  
  function b(f) {
      f()
  }
  </code></pre>
  
  <p>function a() { b(a); }; function b(f) { f(); }; a()
  That will cause a too much recursion error after a while though. Apparently javascript doesn't support tail-recursion so that won't work either. I can't think of any way to use a loop here either since I don't want the code executed immediately. So any way to do this or is it impossible?</p>
  
  <p>Also I apologize if this has been asked before, couldn't find anything that helped.</p>
  
  <p>Edit: Also before anyone asks, no I'm not actually using <code>setTimeout</code> so <code>setIntervall</code> isn't an option.</p>
  
  <p>Edit again: Alright hope this shows what I'm trying to do better. I need to call the same code after waiting for things to complete again without actually putting it in a loop and blocking the program.</p>