<div dir="ltr">What about an approach like this:<div><br></div><div>// require value to be of type UIViewController AND conform to protocol MySpecialProtocol</div><div><font face="monospace, monospace">let specialViewController: (UIViewController &amp; MySpecialProtocol) = …</font></div><div><br></div><div>// require value to be of type Bool OR Double OR String OR SomeProtocol</div><div><font face="monospace, monospace">let value: (Bool | Double | String | SomeProtocol)</font></div><div><font face="monospace, monospace">switch value {</font></div><font face="monospace, monospace">   case let _ as Bool: …</font><div><font face="monospace, monospace">   case let _ as Double: …<br class="">   case let _ as String: …<br class="">   case let _ as SomeProtocol: …</font></div><div><font face="monospace, monospace">   // no default necessary<br></font><div><font face="monospace, monospace">}</font></div><div><br></div></div><div>No need to mess with the &lt;&gt; syntax or requiring the use of any keyword. Just reusing binary logic for types.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 16, 2015 at 3:40 AM, Kevin Ballard via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>




<div><div>Oh that&#39;s clever. I like that. It doesn&#39;t have a big impact on the language and it makes reasonable sense when read. We could also establish convention (possibly backed up by warnings) that says that if Any&lt;...&gt; contains a class, the class name must come first.<br></div>
<div> </div>
<div>-Kevin Ballard<br></div><div><div class="h5">
<div> </div>
<div>On Tue, Dec 15, 2015, at 06:27 PM, Jordan Rose via swift-evolution wrote:<br></div>
<blockquote type="cite"><div>At one point we talked about co-opting &quot;Any&quot; for this purpose, i.e. replacing the &quot;protocol&lt;…&gt;&quot; syntax with &quot;Any&lt;…&gt;&quot;. Like a concrete type, you&#39;re not required to provide arguments, so &quot;Any&quot; by itself doesn&#39;t change meaning. Like an inheritance clause, the compiler would check if you ever had more than one class there.<br></div>
<div> </div>
<div>Jordan<br></div>
<div> </div>
<div><blockquote type="cite"><div>On Dec 4, 2015, at 23:38 , Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" target="_blank">jtbandes@gmail.com</a>&gt; wrote:<br></div>
<div> </div>
<div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" dir="ltr"><div>I think this is a very useful feature of Obj-C that I&#39;ve missed several times while writing Swift code.<br></div>
<div> </div>
<div>However, calling it &quot;TheClass&lt;Protocol1, Protocol2&gt;&quot; directly conflicts with the syntax for specifying generic type parameters.<br></div>
<div> </div>
<div>If we use &quot;protocol&lt;TheClass, Protocol1, Protocol2&gt;&quot; for this case, then `protocol` stops making sense. Maybe the keyword `class` could be allowed instead, like &quot;class&lt;TheClass, Protocol1, Protocol2&gt;&quot;.<br></div>
<div> </div>
<div>Or, it might work to omit the keyword entirely, leaving only the angle brackets:<br></div>
<div> </div>
<div><span style="font-family:monospace,monospace">class C {</span><br></div>
<div><span style="font-family:monospace,monospace">    weak var delegate: &lt;UIViewController, UICollectionViewDelegate&gt;?</span><br></div>
<div><span style="font-family:monospace,monospace">}</span><br></div>
<div> </div>
<div><span style="font-family:monospace,&#39; monospace&#39;">if let task = object as? &lt;NSManagedObject, Task&gt; {</span><br></div>
<div><span style="font-family:monospace,&#39; monospace&#39;">    task.coreDataRelatedFunction()</span><br></div>
<div><span style="font-family:monospace,&#39; monospace&#39;">    task.taskRelatedFunction()</span><br></div>
<div><div><span style="font-family:monospace,&#39; monospace&#39;">}<br></span></div>
<div><div> </div>
<div><div><div dir="ltr"><div>Jacob Bandes-Storch<br></div>
</div>
</div>
</div>
<div> </div>
<div><div>On Fri, Dec 4, 2015 at 3:07 PM, Daniel Muhra<span></span><span dir="ltr">&lt;<a href="mailto:daniel.muhra@gmail.com" target="_blank">daniel.muhra@gmail.com</a>&gt;</span><span></span>wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left: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"><div>Currently it doesn’t seem possible to define a property or variable of a specific class that also implements one or more protocols.<br></div>
<div>Take as an example the following definition from Objective C:<br></div>
<div> </div>
<div>NSManagedObject&lt;NSCoding, Task&gt;* someObject;<br></div>
<div> </div>
<div>To my knowledge, currently it is only possible to define multiple protocols only:<br></div>
<div> </div>
<div>var object : protocol&lt;NSCoding, Task&gt;<br></div>
<div> </div>
<div>However, given the first example, sometimes it is not possible to restrict to protocols only. This becomes especially cumbersome, if you would need to cast down to such a construct within a single method and perform several steps which would require all those type information:<br></div>
<div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo"> </div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">func</span><span></span>doSomething(object:<span></span><span style="color:rgb(112,61,170)">AnyObject</span>) {<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo"><span></span><span style="color:rgb(187,44,162)">if</span><span></span><span style="color:rgb(187,44,162)">let</span><span></span>managedObject = object<span></span><span style="color:rgb(187,44,162)">as</span>?<span></span><span style="color:rgb(112,61,170)">NSManagedObject</span><span></span>{<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span><span></span></span>// Do core data related stuff<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo"><span></span>}<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"> </div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo"><span></span><span style="color:rgb(187,44,162)">if</span><span></span><span style="color:rgb(187,44,162)">let</span><span></span>task = object<span></span><span style="color:rgb(187,44,162)">as</span>?<span></span><span style="color:rgb(79,129,135)">Task</span><span></span>{<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span><span></span></span>// Do task related stuff<br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo"><span></span>}  <br></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:11px;line-height:normal;font-family:Menlo">}<br></div>
</div>
<div> </div>
<div>In this case you now have managedObject and task though you operate on the same object. Also it is not (easily) possible to interleave actions of those two.<br></div>
<div> </div>
<div>My first idea here would be to introduce an Objective C like style of type naming. This also has the benefit, that it is perfectly clear, whether a type name refers to a class or a protocol (without first having to check it).<br></div>
<div>The downside, of course, is that protocol type variables would become something like Any&lt;MyProtocol&gt;<br></div>
<div> </div>
<div>Any other ideas are welcome, but the initial problem still stands and should be addressed.<br></div>
<div><img style="min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:0px!important;padding-top:0px!important;padding-right:0px!important;padding-bottom:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/fd56f32021fabb20ed3f7517094abddf036d06b177de7d04f288f7139de36e71/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d305d2232437952624a584252457c44424a416c4434494b444e466b6b6a60725f4f67745972514f42665131317a7143464939525578757d6951456f436a6d424d45425c684265523d697668396f616f43707d223240545f6d45786839353148776a663c4477754257535c607c49316b43735d42513c68464d437b6363553d223248646d6b616d696158347244403735747644447b627c65725638473f4461614943487a4570546d6b476a783e663f6d6e687954546856783254645a46515547636d223642307d22364d22364745596038594252575d6835427f625d445254743f6d22364b4148686d22364373557e4b694d6a74553e6a4f61674e4f6d23344/open"><br></div>
</div>
<div> </div>
<div>_______________________________________________<br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
<div> </div>
</blockquote></div>
<div> </div>
</div>
</div>
</div>
<div><img style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-right:0px!important;margin-bottom:0px!important;margin-left:0px!important;padding-top:0px!important;padding-right:0px!important;padding-bottom:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/c81ace139430653ffb1201803ab6d7457d69e6d80fc1bb5011b161ca2682c603/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3a554a743178495e6858605273326240557d2236487054347e433846675b4c4d2236447a40717b6150376b6f46535344753862467d6252674d22364d496937416349736677533d454c6c4439377d4071473e6660536146475237326346396d476d22364a766661684e4441675954424d63785b47384373605831375251735947473e654e617c61644b664655544a52533672654d22324d22324659344f624549693a616e4354566770763a5b4776535458343f67396667463f4f6f4d223244493c623d685a446d22324a585868657b62317f4a456a7932576868456f4e654767364773485266623275654e6864317c605b6d223647354a5c6851703e636d23344/open"><span style="font-family:Helvetica"><span style="font-size:12px"><span></span>_______________________________________________</span></span><br></div>
<div><span style="font-family:Helvetica"><span style="font-size:12px">swift-evolution mailing list</span></span><br></div>
<div><a style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><a style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</div>
</blockquote></div>
<div> </div>
<div> <img style="min-height:1px!important;width:1px!important;border-top-width:0px!important;border-right-width:0px!important;border-bottom-width:0px!important;border-left-width:0px!important;margin-top:0px!important;margin-bottom:0px!important;margin-right:0px!important;margin-left:0px!important;padding-top:0px!important;padding-bottom:0px!important;padding-right:0px!important;padding-left:0px!important" border="0" height="1" width="1" alt="" src="https://www.fastmailusercontent.com/proxy/a34bb4f2b4d206e1f95184c5793f7d9800e398b6e63a3e28501ea829d5231d33/8647470737a3f2f25723030323431303e23647e23756e64676279646e2e65647f27766f2f60756e6f35707e6d3148765176786c673171614a7d2236454230345272776e455447423037463b6d4a407673655f486c6d6753695a66736460735a623b4943317d4972525a4346363930786256707a49557d653d684e45313e6d6c41456d453575394a555f677d67637463367358505667785e6567393249356c4675495633517662615c4a46525d4570716d2236435a6330305733684b463d4d22324470783c6474537f4f6442464a665249554d6844647a5a6f65675c63683879626a7c435a427745565a77396d667f4b4d22324d685d49557f405d68573a52563a64455e61665f4a423e476d23344d23344/open"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div> </div>

<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=6ZGE61OxINd5lLe2xYh9Ku-2BXbixWNr2nvfzp2IB1sZhwwzwDoYy1e-2B0Fi2HtVJJg5U-2FFBbszw5BoIz8j5f1YKwNSWCsbRfZH3ZVoPysUvZv0Eg6s4Wf-2BZi7Mb3gzsX4FFVFlpX9-2B9DFZeZlDakOoa0l-2FtOPrEdZtYTlfbNNVRn-2Fdk-2BHbSYVjcg9lJEQGij-2FIsd3otO5Z8L98G3fXZTsvcA-3D-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div></div></div>


<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">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>
<br></blockquote></div><br></div>