title: Interpreters: Handling includes/imports
body: <p>I've built an interpreter in C++ and everything works fine so far, but now I'm getting stuck with the design of the import/include/however you want to call it function.</p>
  
  <p>I thought about the following:</p>
  
  <ul>
  <li><p>Handling includes in the tokenizing process: When there is an <code>include</code> found in the code, the tokenizing function is recursively called with the filename specified. The tokenized code of the <code>include</code>d file is then added to the prior position of the include.
  Disadvantages: No conditional includes(!)</p></li>
  <li><p>Handling includes during the interpreting process: I don't know how. All I know is that PHP <code>must</code> do it this way as conditional includes are possible.</p></li>
  </ul>
  
  <p>Now my questions:</p>
  
  <ul>
  <li>What should I do about includes?</li>
  <li>How do modern interpreters (Python/Ruby) handle this? Do they allow conditional includes?</li>
  </ul>