title: indirect enums and structs
body: <p>To start off, I want to say that I'm aware there are <strong>many</strong> articles and questions within SO that refer to the <code>indirect</code> keyword in Swift. </p>
  
  <p>The most popular explanation for the usage of <code>indirect</code> is to allow for recursive enums. </p>
  
  <p>Rather than just knowing about what <code>indirect</code> allows us to do, I would like to know <strong>how</strong> it allows us to use recursive enums.</p>
  
  <h2>Questions:</h2>
  
  <p>Is it because enums are value types and value types do not scale well if they are built in a recursive structure? Why?</p>
  
  <p>Does <code>indirect</code> modify the value type behaviour to behave more like a reference type? </p>
  
  <p>The following two examples compile just fine. What is the difference?</p>
  
  <pre><code>indirect enum BinaryTree&lt;T&gt; {
    case node(BinaryTree&lt;T&gt;, T, BinaryTree&lt;T&gt;)
    case empty
  }
  
  enum BinaryTree&lt;T&gt; {
    indirect case node(BinaryTree&lt;T&gt;, T, BinaryTree&lt;T&gt;)
    case empty
  }
  </code></pre>