Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>None of the code you show is using recursion. When you call <code>useFile</code> it calls <code>posix.stat()</code>, which returns, and <code>useFile</code> terminates as it has run to completion. At some later time, when the call to <code>posix.stat()</code> has completed <em>within the underlying system</em> and the results are available, the callback function you added for that will be executed. That calls <code>posix.open()</code>, and then terminates as it has run to completion. Once the file has been successfully opened, the callback function for <em>that</em> will execute, calling <code>posix.read()</code>, and will then terminate as it, too, has run to completion. Finally, when the results of the read are available, the innermost function will be executed.</p> <p>The important point is that each function runs to completion, as the calls to the <code>posix.*()</code> functions are non-blocking: that is, they return immediately, having caused some magic to be started off in the underlying system. So each of your functions terminates, and later an event will cause the next function to execute; but at no point is there any recursion.</p> <p>The nested structure of the code can give one the impression that the stuff inside will have to finish before the stuff outside can get to its own end point. But in this style of asynchronous event-driven programming it makes more sense to see the nesting in terms of <em>deeper => happens-later-than</em>.</p> <p>EDIT: Try adding some logging statements immediately before the end of each nested function; this will help to illustrate that the order in which they complete is from the outside inwards.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload