<head></head><body>Why not separate the reference and its info? That way you can make the reference weak.<div><div><br></div><div><p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">enum ParentChildRelationship {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> case Son</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> case Daughter</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">}</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br></p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">class Parent {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> lazy var son: Child = Child(sonOf: self)</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> lazy var daughter: Child = Child(daughterOf: self)</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"> deinit { print("deinit Parent") }</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">}</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br></p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">class Child {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> weak var parent: Parent?</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> var parentRelationship: ParentChildRelationship</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">        </p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> init(parent: Parent, relationship: ParentChildRelationship) {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> self.parent = parent</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> self.parentRelationship = relationship</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> }</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">        </p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> convenience init(sonOf parent: Parent) {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> self.init(parent: parent, relationship: .Son)</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> }</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> </p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> convenience init(daughterOf parent: Parent) {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> self.init(parent: parent, relationship: .Daughter)</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> }</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"> </p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"> deinit { print("deinit Child") }</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">}</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br></p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><br></p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">do {</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> let parent = Parent()</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> parent.son</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"> parent.daughter</p>
<p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;">}</p><p style="margin-bottom: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;"><br></p></div><br><!-- <signature> --><b>Patrick Smith</b><br><!-- </signature> --></div><div class="gmail_quote">
On May 4 2016, at 1:07 am, Marc Prud'hommeaux via swift-evolution <swift-evolution@swift.org> wrote:
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<meta content="text/html charset=us-ascii"><div><br></div><div>The following code currently has a retain cycle and memory leak:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">enum</span><span style="font-variant-ligatures: no-common-ligatures"> ParentChild {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">case</span><span style="font-variant-ligatures: no-common-ligatures"> SonOf(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Parent</span><span style="font-variant-ligatures: no-common-ligatures">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">case</span><span style="font-variant-ligatures: no-common-ligatures"> DaughterOf(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Parent</span><span style="font-variant-ligatures: no-common-ligatures">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">class</span><span style="font-variant-ligatures: no-common-ligatures"> Parent {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">lazy</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">var</span><span style="font-variant-ligatures: no-common-ligatures"> son: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures">(parentChild: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">SonOf</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">self</span><span style="font-variant-ligatures: no-common-ligatures">))</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">lazy</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">var</span><span style="font-variant-ligatures: no-common-ligatures"> daughter: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures">(parentChild: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">DaughterOf</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">self</span><span style="font-variant-ligatures: no-common-ligatures">))</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(180, 38, 26);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">deinit</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures">"deinit Parent"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">class</span><span style="font-variant-ligatures: no-common-ligatures"> Child {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">var</span><span style="font-variant-ligatures: no-common-ligatures"> parentChild: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">ParentChild</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">init</span><span style="font-variant-ligatures: no-common-ligatures">(parentChild: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">ParentChild</span><span style="font-variant-ligatures: no-common-ligatures">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">parentChild</span><span style="font-variant-ligatures: no-common-ligatures"> = parentChild</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(180, 38, 26);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">deinit</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures">"deinit Child"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">do</span><span style="font-variant-ligatures: no-common-ligatures"> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">let</span><span style="font-variant-ligatures: no-common-ligatures"> parent = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Parent</span><span style="font-variant-ligatures: no-common-ligatures">()</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> parent.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">son</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> parent.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">daughter</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div>Child.parentChild cannot be declared unowned because ParentChild is a value type. I propose adding the ability to declare the reference storage class for an enum's associated value, like so:</div><div><br></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">enum</span><span style="font-variant-ligatures: no-common-ligatures"> ParentChild {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">case</span><span style="font-variant-ligatures: no-common-ligatures"> SonOf(unowned Parent)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">case</span><span style="font-variant-ligatures: no-common-ligatures"> DaughterOf(unowned Parent)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures: no-common-ligatures">The only current alternative is to have some intermediate reference type that itself holds the reference, akin to the old "Box" type that we used to use to work around enum limitations. E.g., this is our current cumbersome work-around:</span></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures: no-common-ligatures"><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);"><span style="font-variant-ligatures: no-common-ligatures">/// An unowned reference to a value, which is useful for maintaining parent-child relations through value types like enums</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">public</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">struct</span><span style="font-variant-ligatures: no-common-ligatures"> UnownedRef<T: AnyObject></span><span style="font-variant-ligatures: no-common-ligatures"> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(4, 51, 255);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">public</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">unowned</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> value: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">T</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">public</span><span style="font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">init</span><span style="font-variant-ligatures: no-common-ligatures;">(</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">_</span><span style="font-variant-ligatures: no-common-ligatures;"> value: </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">T</span><span style="font-variant-ligatures: no-common-ligatures;">) { </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(4, 51, 255);">self</span><span style="font-variant-ligatures: no-common-ligatures;">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(52, 149, 175);">value</span><span style="font-variant-ligatures: no-common-ligatures;"> = value }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">enum</span><span style="font-variant-ligatures: no-common-ligatures"> ParentChild {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">case</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> SonOf(</span><span style="font-variant-ligatures: no-common-ligatures">UnownedRef</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"><</span><span style="font-variant-ligatures: no-common-ligatures">Parent</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">>)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">case</span><span style="font-variant-ligatures: no-common-ligatures"> DaughterOf(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">UnownedRef</span><span style="font-variant-ligatures: no-common-ligatures"><</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Parent</span><span style="font-variant-ligatures: no-common-ligatures">>)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">class</span><span style="font-variant-ligatures: no-common-ligatures"> Parent {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">lazy</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">var</span><span style="font-variant-ligatures: no-common-ligatures"> son: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures">(parentChild: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">SonOf</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">UnownedRef</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">self</span><span style="font-variant-ligatures: no-common-ligatures">)))</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">lazy</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">var</span><span style="font-variant-ligatures: no-common-ligatures"> daughter: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures"> = </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">Child</span><span style="font-variant-ligatures: no-common-ligatures">(parentChild: .</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">DaughterOf</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">UnownedRef</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">self</span><span style="font-variant-ligatures: no-common-ligatures">)))</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(180, 38, 26);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">deinit</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures">"deinit Foo"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">class</span><span style="font-variant-ligatures: no-common-ligatures"> Child {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">var</span><span style="font-variant-ligatures: no-common-ligatures"> parentChild: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">ParentChild</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">init</span><span style="font-variant-ligatures: no-common-ligatures">(parentChild: </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">ParentChild</span><span style="font-variant-ligatures: no-common-ligatures">) {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">parentChild</span><span style="font-variant-ligatures: no-common-ligatures"> = parentChild</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"> }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;"><span style="font-variant-ligatures: no-common-ligatures"></span><br></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(180, 38, 26);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #0433ff">deinit</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> { </span><span style="font-variant-ligatures: no-common-ligatures; color: #3495af">print</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures">"deinit Child"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">) }</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div></span></div><div><span style="font-variant-ligatures: no-common-ligatures">The storage type of an enum would, of course, be limited to reference types, and when the storage class is weak, it would require that the stored type be Optional, just like when declaring a weak variable.</span></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures: no-common-ligatures">What do people think?</span></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures: no-common-ligatures"><span style="white-space:pre">        </span>-Marc</span></div><div><br></div>
</blockquote>
</div></body>