<div dir="ltr">I think there would be a certain elegance to allowing Boolean type expressions wherever types are currently allowed, so `A &amp; B` being a replacement for `protocol&lt;A, B&gt;` might look nice, and then extend that to allow concrete types as well. Then, if Swift ever decided to support union types, the `|` operator naturally fits there.<div><br></div><div>One concern though would be whether parsing would get more complicated with deeply composed expressions. If we only supported `&amp;`, there&#39;s no real nesting going on. But if we wanted to be forward thinking and leave the door open for `|`, we might need to support things like `(String | Int) &amp; SomeProtocol`, and I&#39;m not enough of a parser expert to know whether that would really complicate things (e.g., could the compiler decide easily enough that those parentheses are part of a type expression and not a function type?).</div><div><br></div><div>`all&lt;A, B&gt;` would be a nice compromise in that case, and leave the door open for `any&lt;A, B&gt;` in the future. So I&#39;d be supportive of either option.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, May 12, 2016 at 1:30 PM Jordan Rose via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>We&#39;ve been over this a few times before on the list. I personally like naming this thing &quot;Any&lt;…&gt;&quot; in the same vein as &quot;AnyObject&quot;, &quot;AnyClass&quot;, and &quot;AnySequence&quot;. I also see Thorsten (and in the past Brent&#39;s?) argument for calling it &quot;all&quot; or &quot;All&quot;, because it&#39;s enforcing multiple constraints.</div><div><br></div><div>I will say that &quot;type&quot; is unlikely to see much traction simply because it is an <i>incredibly</i> common name for both properties and locals. We went through that exercise when trying to name both &quot;static&quot; and &quot;dynamicType&quot; and decided that it would be too confusing, even if we could make the parsing work.</div><div><br></div><div>The feature itself has definitely been shown to be useful when working with the Cocoa frameworks, if not in general. I don&#39;t see it on JIRA yet but we have it internally tracked in Radar as <a>rdar://problem/15873071</a>.</div></div><div style="word-wrap:break-word"><div><br></div><div>Jordan</div></div><div style="word-wrap:break-word"><div><br></div><br><div><blockquote type="cite"><div>On May 12, 2016, at 13:08, Adrian Zubarev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">I don’t get the part how `all&lt;&gt;` should allow `any&lt;&gt;`. Could you explain that a little bit in detail (I’m not familiar with Ceylon)?</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">From my point of view `any&lt;&gt;` is something different that I pitched here. `any&lt;&gt;` could be proposed in its own thread, because it is way different than `type&lt;&gt;`. Or can we refine the rules of `type&lt;&gt;` to get to `any&lt;&gt;`?</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">Here is a little example where `any&lt;&gt;` gets strange:</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">func foo(value: any&lt;String, Int&gt;) -&gt; any&lt;String, Int&gt; {</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">    // how would one use value here?</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">    // what about its properties</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">    // what will foo return and how to use the result</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">}</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">One benefit of `any&lt;&gt;` is the replacement of overloading, at least for the type part of the function.</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">I’d like to propose `type&lt;&gt;` as the base extension to the language in that direction, before we’ll move forward with more complex scenarios (just like Chris did with generic typealias).</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">This function is clear that it only will work if you provide a subclass of an UIView which conforms to SomeProtocol (nice addition for library design).</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><div style="margin:0px">func foo(value: type&lt;UIView, SomeProtocol&gt;) -&gt; type&lt;UIView, SomeProtocol&gt; {</div><div style="margin:0px"><br></div><div style="margin:0px">    // use it as a UIView and SomeProtocol at the same type</div><div style="margin:0px">    return value // return type works great</div><div style="margin:0px">}</div><div style="margin:0px"><br></div><div style="margin:0px">We can split the value just fine:</div><div style="margin:0px"><br></div><div style="margin:0px">let mergedValue = foo(SomeViewThatWorks)</div><div style="margin:0px">let view: UIView = mergedValue</div><div style="margin:0px">let protocolValue: SomeProtocol = mergedValue</div><div style="margin:0px"><br></div><div style="margin:0px">And merge it back together:</div></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">guard let newMergedValue = view as? type&lt;UIView, SomeProtocol&gt; else { /* do something */ }</div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><br></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px">`all&lt;&gt;` could be seen as an alternative name for `type&lt;&gt;`, but to me its not clear what `all&lt;&gt;` can do, <span style="font-family:arial,sans-serif;white-space:nowrap">whereas `type&lt;&gt;` is almost like `protocol&lt;&gt;`.</span></div><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><p style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Am 12. Mai 2016 bei 21:40:24, Thorsten Seitz (<a href="mailto:tseitz42@icloud.com" target="_blank">tseitz42@icloud.com</a>) schrieb:</p><blockquote type="cite" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span><div style="word-wrap:break-word"><div></div><div>Ceylon uses „&amp;&quot; for intersection types, i.e.<div><br></div><div>SomeRealClass &amp; SomeProtocol</div><div><br></div><div>and the bar („|“) for union types, i.e. </div><div><br></div><div>String | Int</div><div><br></div><div>That has proven to be very lightweight and readable in Ceylon where it is heavily used to good effect.</div><div><br></div><div><br></div><div>I agree with you that</div><div><br></div><div>type&lt;SomeRealClass, SomeProtocol&gt; </div><div><br></div><div>is much nicer than protocol&lt;&gt; for intersection types but to keep the door open for union types, I would prefer</div><div><br></div><div>all&lt;SomeRealClass, SomeProtocol&gt;</div><div><br></div><div>This would allow</div><div><br></div><div>any&lt;String, Int&gt;</div><div><br></div><div>to be used for union types.</div><div><br></div><div>-Thorsten</div><div><br></div><div><br><div><blockquote type="cite"><div>Am 12.05.2016 um 16:09 schrieb Adrian Zubarev via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;:</div><br><div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:&#39;helvetica Neue&#39;,helvetica">protocol&lt;SomeRealClass, SomeProtocol&gt; </span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:&#39;helvetica Neue&#39;,helvetica">protocol&lt;SomeRealStruct, SomeProtocol&gt; </span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:&#39;helvetica Neue&#39;,helvetica"><br></span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:&#39;helvetica Neue&#39;,helvetica;font-size:13px">This feels really odd to me. </span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:&#39;helvetica Neue&#39;,helvetica;font-size:13px"><br></span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:&#39;helvetica Neue&#39;,helvetica;font-size:13px">`type&lt;</span><span style="font-family:&#39;helvetica Neue&#39;,helvetica;font-size:13px">SomeRealClass, </span><span style="font-family:&#39;helvetica Neue&#39;,helvetica;font-size:13px">SomeProtocol</span><font face="helvetica Neue, helvetica">&gt;` is more clear I’d say.</font></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><font face="helvetica Neue, helvetica"><br></font></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><font face="helvetica Neue, helvetica">I think this would be a good </font><span style="font-family:arial,sans-serif;white-space:nowrap">addition to the type system and allow us to build more complex and type save code.</span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><span style="font-family:arial,sans-serif;white-space:nowrap"><br></span></div><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px"><font face="arial, sans-serif"><span style="white-space:nowrap">But still I’d love to discuss if there might be any disadvantages to this feature.</span></font></div><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><p style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Am 12. Mai 2016 bei 15:11:00, Vladimir.S (<a href="mailto:svabox@gmail.com" target="_blank">svabox@gmail.com</a>) schrieb:</p><blockquote type="cite" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><span><span style="font-family:&#39;helvetica Neue&#39;,helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">protocol&lt;&gt;<span> </span></span></span></div></blockquote><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br></div></div></div></span></blockquote><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica,Arial;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div><br></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>