<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 4, 2016, at 2:31 PM, Adrian Zubarev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">I kinda feel my idea went into the wrong direction.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class="">By introducing these implicit protocols (formatted with Source Code Pro font) I didn’t meant them to force a type to have only reference or value&nbsp;<span style="font-family: 'helvetica Neue', helvetica;" class="">semantics.</span></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+-------+</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp;Any &nbsp;|</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+---+---+</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;+-------------+-------------+</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; +------+-------+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +-----+----+</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; | AnyReference | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | AnyValue |</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; +------+-------+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +-----+----+</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">+--------+---------+ &nbsp;....................................</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">| AnyObject (ObjC) | &nbsp;: Optionally Swift could also have :</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">+------------------+ &nbsp;: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : &nbsp; &nbsp; &nbsp;+-------+--------+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;:</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : +----+----+ &nbsp; &nbsp; +-----+-----+ &nbsp; &nbsp;:</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : | AnyEnum | &nbsp; &nbsp; | AnyStruct | &nbsp; &nbsp;:</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><font face="SourceCodePro-Regular" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; : +----+----+ &nbsp; &nbsp; +-----+-----+ &nbsp; &nbsp;:</font></div><div id="bloop_customfont" style="margin: 0px;" class=""><span style="font-family: SourceCodePro-Regular;" class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ....................................</span></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">Array&lt;UIView&gt; is a great example that `AnyValue` should not restrict your type to contain only value types.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">The main idea behind these implicit protocols was the ability to create protocols which only can be applied to a specific type (class, struct or enum, maybe tuples one day) or to distinguish between types.</div></div></div></blockquote><div><br class=""></div>And the point others have made is that the value in this is less than it might seem at first glance. &nbsp;Semantic clarity in generic code requires protocols to have semantics attached to them. &nbsp;</div><div><br class=""><blockquote type="cite" class=""><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">Here are some simple examples:&nbsp;</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">protocol MagicValueType: AnyValue {}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">extension MagicValueType {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">&nbsp; &nbsp; &nbsp; func expectoPatronum() { /* do some amazing magic */ }</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">&nbsp; &nbsp; &nbsp; func getMeAView() -&gt; UIView { return UIView() }&nbsp;</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">&nbsp; &nbsp; &nbsp; // AnyValue should not forbid value types to work with reference types</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">class A {}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">struct B {}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">extension A: MagicValueType {} // this should NOT work and produce an error, because MagicValueType is restricted to value types only</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">extension B: MagicValueType {} // wow we extended our type with an value type protocol (this is new to the language)</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">Same rules goes to the `AnyReference`.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">We already can do something like this:</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">protocol SomeReferenceProtocol: class {} // restricted to classes only</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">extension SomeReferenceProtocol {</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">&nbsp; &nbsp; &nbsp;func foo() -&gt; B { return B() } // we can work with value or reference types as we pleased</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">extension A: SomeReferenceProtocol {} // works as expected</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">extension B: SomeReferenceProtocol {} // this already produces an error which is the way it should work</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">I’d be great if we change the `class` keyword to `AnyReference` (not @objc protocol AnyObject {} as explained before).</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">protocol SomeReferenceProtocol: AnyReference {}</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">Any value type except buildin types (Tuples can’t be extended at the moment anyways) should implicitly conform to AnyValue and any Swift classes should implicitly conform to AnyReference. All ObjC classes should conform to AnyObject.</div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class="">If these protocols would exist we could use them to overload correctly (an abstract example I used in my post two weeks ago):</div><div id="bloop_customfont" style="margin: 0px;" class=""><pre style="font-size: 13px; font-family: Helvetica, Arial; white-space: pre-wrap;" class="">func mutate&lt;T: AnyValue&gt;(value: T, scope: @noescape (value: inout T) -&gt; Void) -&gt; T {
                        
&nbsp; &nbsp; var mutableValue = value
&nbsp; &nbsp; scope(value: &amp;mutableValue)
&nbsp; &nbsp; return mutableValue
}

func mutate&lt;T: AnyReference&gt;(value: T, scope: @noescape (value: T) -&gt; Void) -&gt; T {
                        
&nbsp; &nbsp; scope(value: value)
&nbsp; &nbsp; return value
}</pre><pre style="font-size: 13px; font-family: Helvetica, Arial; white-space: pre-wrap;" class="">The first `mutate` function will be called if you pass any class to it, including ObjC classes. And finally the second `mutate` function is only called when there is a value type (struct, enum).<span style="font-family: Helvetica, Arial;" class=""> </span></pre></div></div></div></blockquote><div>You have “first” and “second” backwards here.</div><div><br class=""></div><div>I really like that you bring up this example. &nbsp;Ideally two overloads would not be necessary here. &nbsp;I haven’t thought deeply about whether a solution enabling a single implementation is possible and if so what it might look like. &nbsp;If there is a solution it would be much more elegant than requiring the overloads.</div><blockquote type="cite" class=""><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class=""><pre class=""><font face="Helvetica, Arial" class=""><span style="white-space: pre-wrap;" class="">I don’t want to restrict the semantics of a type with implicit protocol, but just to constrain protocols if there is a need and correctly detect reference vs. value types. </span></font></pre><pre class=""><font face="Helvetica, Arial" class=""><span style="white-space: pre-wrap;" class="">We could go even further and allow mixing of implicit protocols:</span></font></pre><pre class=""><font face="Helvetica, Arial" class=""><span style="white-space: pre-wrap;" class="">protocol C</span></font><span style="font-family: Helvetica, Arial;" class="">ocktail: AnyReference, AnyValue {}</span></pre><pre class=""><font face="Helvetica, Arial" class="">this would be equivalent to:&nbsp;</font></pre><pre class=""><font face="Helvetica, Arial" class=""><span style="white-space: pre-wrap;" class="">protocol C</span></font><span style="font-family: Helvetica, Arial;" class="">ocktail: Any {}</span></pre><pre class=""><span style="font-family: Helvetica, Arial;" class="">or just:</span></pre><pre class=""><font face="Helvetica, Arial" class=""><span style="white-space: pre-wrap;" class="">protocol C</span></font><span style="font-family: Helvetica, Arial;" class="">ocktail {}</span></pre></div></div></div></blockquote><div><br class=""></div><div>No, this under your suggestion this would require conforming types to conform to both AnyReference and AnyValue which would be impossible given your definitions.</div><br class=""><blockquote type="cite" class=""><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class=""><pre class=""><span style="font-family: Helvetica, Arial;" class="">Complex restriction might also be possible for whatever desire:</span></pre><pre class=""><span style="font-family: Helvetica, Arial;" class="">protocol Burger: AnyObject, AnyStruct {}</span></pre><pre class=""><font face="Helvetica, Arial" class="">extension UIView: </font><span style="font-family: Helvetica, Arial;" class="">Burger{} and extension B: </span><span style="font-family: Helvetica, Arial;" class="">Burger&nbsp;{} should work.</span></pre></div></div></div></blockquote><div>This would be a compiler error as UIView clearly would not conform to AnyStruct. &nbsp;</div><div><div class=""><br class=""></div></div><br class=""><blockquote type="cite" class=""><div class=""><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; margin: 0px;" class=""><div id="bloop_customfont" style="margin: 0px;" class=""><pre class=""><span style="font-family: Helvetica, Arial;" class="">I home my English was enough to clarify my idea.</span></pre></div></div><div id="bloop_sign_1462388061478033920" class="bloop_sign" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="font-family: helvetica, arial; font-size: 13px;" class="">--&nbsp;<br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><p class="airmail_on" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Am 4. Mai 2016 bei 20:46:40, Matthew Johnson via swift-evolution (<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>) schrieb:</p><blockquote type="cite" class="clean_bq" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class=""><div class=""><div class=""></div><div class=""><br class="">&gt; On May 4, 2016, at 1:29 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; on Wed May 04 2016, Adrian Zubarev &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;&gt; Not sure what to think about the enum cases inside a protocol (if AnyEnum would<br class="">&gt;&gt; even exist), it could be a nice addition to the language, but this is an own<br class="">&gt;&gt; proposal I guess.<br class="">&gt;&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;&gt; We should start by adding AnyValue protocol to which all value types<br class="">&gt;&gt; conforms.<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; Having a way to constrain conformance to things with value semantics is<br class="">&gt; something I've long wanted. *However*, the approach described is too<br class="">&gt; simplistic. It's possible to build classes whose instances have value<br class="">&gt; semantics (just make them immutable) and it's possible to build structs<br class="">&gt; whose instances have reference semantics (just put the struct's storage<br class="">&gt; in a mutable class instance that it holds as a property, and don't do<br class="">&gt; copy-on-write).<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; In order for something like AnyValue to have meaning, we need to impose<br class="">&gt; greater order. After thinking through many approaches over the years, I<br class="">&gt; have arrived at the (admittedly rather drastic) opinion that the<br class="">&gt; language should effectively outlaw the creation of structs and enums<br class="">&gt; that don't have value semantics. (I have no problem with the idea that<br class="">&gt; immutable classes that want to act as values should be wrapped in a<br class="">&gt; struct). The language could then do lots of things much more<br class="">&gt; intelligently, such as correctly generating implementations of equality.<br class=""><br class="">That is a drastic solution indeed! How would this impact things like Array&lt;UIView&gt;? While Array itself has value semantics, the aggregate obviously does not as it contains references which usually be mutated underneath us. Similar considerations apply to simpler wrapper structs such as Weak.<br class=""><br class="">My expectation is a generic aggregate such as Array would have to conditionally conform to AnyValue only when Element also conforms to AnyValue.<br class=""><br class="">I’m also wondering how such a rule would be implemented while still allowing for CoW structs that *do* implement value semantics, but do so while using references internally.<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">If the compiler can be sophisticated enough to verify value semantics statically maybe it would be better to have that mechanism be triggered by conformance to AnyValue rather than for all structs and enums. Types that conform to AnyValue would receive the benefits of the compiler knowing they have value semantics, while other uses of structs and enums would remain valid. Best practice would be to conform structs and enums to AnyValue whenever possible.<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span><br class=""><br class="">Another possible advantage of this approach would be allowing immutable reference types to conform to AnyValue and receive the associated benefits such as the generated implementation of equality, etc.<br class=""><br class="">-Matthew<br class=""><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; --<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; Dave<br class="">&gt;<span class="Apple-converted-space">&nbsp;</span><br class="">&gt; _______________________________________________<br class="">&gt; swift-evolution mailing list<br class="">&gt; <a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></span></blockquote><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>