title: Why build an AST walker instead of having the nodes responsible for their own output?
body: <p>Given an AST, what would be the reason behind making a <code>Walker</code> class that walks over the tree and does the output, as opposed to giving each <code>Node</code> class a <code>compile()</code> method and having it responsible for its own output?</p>
  
  <p>Here are some examples:<br>
  <a href="https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/SqlWalker.php" rel="nofollow">Doctrine 2</a> (an ORM) uses a <code>SQLWalker</code> to walk over an AST and generate SQL from nodes.<br>
  <a href="https://github.com/fabpot/Twig/blob/master/lib/Twig/Node/If.php" rel="nofollow">Twig</a> (a templating language) has the nodes output their own code (this is an <code>if</code> statement node).</p>