title: Can I use Lua's require to set environment of the calling file?
body: <p>Is there a way to call <code>require</code> in a Lua file, and have the module set the environment of the file that calls it? For example, if I have a DSL (domain specific language) that defines the functions <code>Root</code> and <code>Sequence</code> defined in a table, can I have something like <code>setfenv(1, dslEnv)</code> in the module that allows me to access those functions like global variables?</p>
  
  <p>The goal I in mind is using this is a behavior tree DSL in a way that makes my definition file look like this (or as close it as possible):</p>
  
  <pre><code>require "behaviortrees"
  
  return Root {
      Sequence {
          Leaf "leafname",
          Leaf "leafname"
      }
  }
  </code></pre>
  
  <p>without having to specifically bring <code>Root</code>, <code>Sequence</code>, and <code>Leaf</code> into scope explicitly or having to qualify names like <code>behaviortrees.Sequence</code>.</p>
  
  <p>In short, I'm trying to make the definition file as clean as possible, without any extraneous lines cluttering the tree definition.</p>