<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br><br>Sent from my iPad</div><div><br>On May 13, 2016, at 9:21 AM, Tony Allevato via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><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></div></blockquote><div><br></div><div>+1</div><div><br></div><div>But maybe we should consider generalizing this to type operators. &nbsp;The '?' For optional could then be a postfix type operator. &nbsp;And we could define our own type operators for type composition. &nbsp;</div><br><blockquote type="cite"><div><div dir="ltr"><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'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'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'd be supportive of either option.</div></div></div></blockquote><div><br></div>This makes sense as an immediate step in the right direction. &nbsp;I like that it is more concise than protocol&lt;&gt;<br><blockquote type="cite"><div><div dir="ltr"><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've been over this a few times before on the list. I personally like naming this thing "Any&lt;…&gt;" in the same vein as "AnyObject", "AnyClass", and "AnySequence". I also see Thorsten (and in the past Brent's?) argument for calling it "all" or "All", because it's enforcing multiple constraints.</div><div><br></div><div>I will say that "type" is unlikely to see much traction simply because it is an <i>incredibly</i>&nbsp;common name for both properties and locals. We went through that exercise when trying to name both "static" and "dynamicType" 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't see it on JIRA yet but we have it internally tracked in Radar as&nbsp;<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">&nbsp; &nbsp; // 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">&nbsp; &nbsp; // 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">&nbsp; &nbsp; // 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,&nbsp;SomeProtocol&gt; {</div><div style="margin:0px"><br></div><div style="margin:0px">&nbsp; &nbsp; // use it as a UIView and SomeProtocol at the same type</div><div style="margin:0px">&nbsp; &nbsp; 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,&nbsp;<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">--&nbsp;<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;" 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.&nbsp;</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;&nbsp;</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:'helvetica Neue',helvetica">protocol&lt;SomeRealClass, SomeProtocol&gt;&nbsp;</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:'helvetica Neue',helvetica">protocol&lt;SomeRealStruct, SomeProtocol&gt;&nbsp;</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:'helvetica Neue',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:'helvetica Neue',helvetica;font-size:13px">This feels really odd to me.&nbsp;</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:'helvetica Neue',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:'helvetica Neue',helvetica;font-size:13px">`type&lt;</span><span style="font-family:'helvetica Neue',helvetica;font-size:13px">SomeRealClass,&nbsp;</span><span style="font-family:'helvetica Neue',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&nbsp;</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&nbsp;disadvantages&nbsp;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">--&nbsp;<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:'helvetica Neue',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>&nbsp;</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>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>