<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 Jan 29, 2017, at 2:25 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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="">On Sun, Jan 29, 2017 at 2:16 PM, Matthew Johnson<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jan 29, 2017, at 2:01 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_3246467056528599417Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">On Sun, Jan 29, 2017 at 1:37 PM, Matthew Johnson<span class="m_3246467056528599417Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.<wbr class="">com</a>&gt;</span><span class="m_3246467056528599417Apple-converted-space">&nbsp;</span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><div class=""><br class=""><br class="">Sent from my iPad</div><span class="m_3246467056528599417gmail-"><div class=""><br class="">On Jan 29, 2017, at 12:58 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Cool. Another avenue of improvement here is relaxing the single-class spelling rule for the sake of composing typealiases.<br class=""><br class="">As Matthew mentioned, if I have class Base and typealiases Foo = Base &amp; Protocol1 and Bar = Base &amp; Protocol2, it'd be nice to allow Foo &amp; Bar.<br class=""><br class="">It'd be nice to go one step further: given class Derived : Base, if I have typealiases Foo2 = Base &amp; Protocol1 and Bar2 = Derived &amp; Protocol2, then it could be permitted to write Foo2 &amp; Bar2, since there is effectively only one subclass requirement (Derived).<br class=""><br class="">As I understand it, the rationale for allowing only one subclass requirement is that Swift supports only single inheritance. Thus, two disparate subclass requirements Base1 &amp; Base2 would make your existential type essentially equivalent to Never. But Base1 &amp; Base1 &amp; Base1 is fine for the type system, the implementation burden (though greater) shouldn't be too awful, and you would measurably improve composition of typealiases.<br class=""></div></blockquote><div class=""><br class=""></div></span><div class="">Yes, this is what I was indicating in my post as well.</div><div class=""><br class=""></div><div class="">Are you suggesting that Base1 &amp; Base2 compose to a type that is treated identically to Never do you think it should be an immediate compiler error?&nbsp; I remember having some discussion about this last year and think somebody came up with a very interesting example of where the former might be useful.</div></div></blockquote><div class=""><br class=""></div><div class="">Last year's discussion totally eludes me for some reason. But sure, if deferring the error until runtime is actually useful then why not? In the absence of an interesting use case, though, I think it'd be nice for the compiler to warn you that Base1 &amp; Base2 is not going to be what you want.</div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Deferring to runtime isn’t what I mean.&nbsp; If you try to actually *do* anything that requires an instance of `Base1 &amp; Based` (which you almost always would) you would still get a compile time error.</div><div class=""><br class=""></div><div class="">I managed to dig up the example from last year’s thread and it is definitely a good one:</div><div class=""><br class=""></div><div class="">func intersection&lt;T, U&gt;(ts; Set&lt;T&gt;, us: Set&lt;U&gt;) -&gt; Set&lt;T &amp; U&gt;</div><div class=""><br class=""></div><div class="">The desire is that we are always able to produce a result set.&nbsp; When T &amp; U is uninhabitable it will simply be an empty set just like Set&lt;Never&gt; has a single value which is the empty set.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Currently, Set&lt;Never&gt; is impossible because Never is not Hashable :)</div></div></div></div></div></blockquote><div><br class=""></div><div>Ahh, good point. &nbsp;I hadn’t tried it. &nbsp;It can easily be made Hashable with a simple extension though - this code compiles today:</div><div><br class=""></div><div>extension&nbsp;Never:&nbsp;Hashable&nbsp;{<br class="">&nbsp; &nbsp;&nbsp;public&nbsp;var&nbsp;hashValue:&nbsp;Int&nbsp;{&nbsp;return&nbsp;0&nbsp;}<br class="">}<br class="">public&nbsp;func&nbsp;==(lhs:&nbsp;Never, rhs:&nbsp;Never) -&gt;&nbsp;Bool&nbsp;{&nbsp;return&nbsp;false&nbsp;}<br class="">let&nbsp;s =&nbsp;Set&lt;Never&gt;()</div><div><br class=""></div><blockquote type="cite" class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Since concrete types *can't* be used, this example seems like it'd be of little use currently. How widely useful would it be to have an intersection facility such as this when T != U even if that restriction were lifted, though? Seems like the only real useful thing you can do with generic Set&lt;T &amp; U&gt; is based on the fact that it'd be Set&lt;Hashable&gt;. Other than those immediate thoughts, I'll have to think harder on this.</div></div></div></div></blockquote><div><br class=""></div><div>Sure, it’s possible that this is the only interesting example and may not have enough value to be worthwhile. &nbsp;But I found it interesting enough that it stuck around in the back of my mind for 8 months! :) &nbsp;</div><div><br class=""></div><div>It generalizes easily to any cases where you have a generic type that is useful despite not necessarily having access to instances of the parameterized type.</div><div><br class=""></div><div>If we allow this, I *think* all uninhabitable types could be unified semantically by making `Never` a protocol and giving them implicit conformance.</div><br class=""><blockquote type="cite" class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">This example points even more strongly in the direction of allowing *any* concrete type to be used, not just classes - even today we could produce uninhabitable existentials like this using value types.</div><div class=""><br class=""></div><div class="">Here’s the link to the thread:<span class="Apple-converted-space">&nbsp;</span><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160523/019463.html" target="_blank" class="">https://lists.swift.org/<wbr class="">pipermail/swift-evolution/<wbr class="">Week-of-Mon-20160523/019463.<wbr class="">html</a></div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="auto" class=""><span class="m_3246467056528599417gmail-"><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Sun, Jan 29, 2017 at 12:41 Austin Zheng &lt;<a href="mailto:austinzheng@gmail.com" target="_blank" class="">austinzheng@gmail.com</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">The "class comes first" requirement made more sense when the proposed syntax was still "Any&lt;T, U, V&gt;", intentionally mirroring how the superclass and conformances are declared on a class declaration (the archives contain more detailed arguments, both pro and con). Now that the syntax is "T &amp; U &amp; V", I agree that privileging the class requirement is counterintuitive and probably unhelpful.<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg"><br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">Austin<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg"><br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt; On Jan 29, 2017, at 10:37 AM, Matt Whiteside via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt; Thanks for writing this proposal David.<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;&gt; On Jan 29, 2017, at 10:13, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;&gt; As Matthew mentioned, the rules can certainly later be relaxed, but given that this proposal has the compiler generating fix-its for subclasses in second position, is there a reason other than stylistic for demanding MyClass &amp; MyProtocol instead of MyProtocol &amp; MyClass?<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;&gt; From a naive perspective, it seems that if the compiler understands my meaning perfectly, it should just accept that spelling rather than complain.<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt; I had that thought too.&nbsp; Since ‘and’ is a symmetric operation, requiring the class to be in the first position seems counter-intuitive.<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt; -Matt<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt; ______________________________<wbr class="">_________________<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt; swift-evolution mailing list<br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<span class="m_3246467056528599417Apple-converted-space">&nbsp;</span><a href="mailto:swift-evolution@swift.org" class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg">&gt;<span class="m_3246467056528599417Apple-converted-space">&nbsp;</span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg" target="_blank">https://lists.swift.org/mail<wbr class="">man/listinfo/swift-evolution</a><br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg"><br class="m_3246467056528599417gmail-m_-1279302232438251699gmail_msg"></blockquote></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">______________________________<wbr class="">_________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailma<wbr class="">n/listinfo/swift-evolution</a></span></div></blockquote></span></div></blockquote></div></div></div></div></blockquote></span></div></div></blockquote></div></div></div></blockquote></div><br class=""></body></html>