<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=""><div class="">Maybe the restriction of being a class wouldn’t have to do anyting in the protocol definition and it is more a concern of who is managing an element (conforming that protocols and some others).</div><div class=""><br class=""></div><div class="">Avoiding &nbsp;protocol modifiers and then when using it and if needed:</div><div class=""><br class=""></div><div class=""><font face="Courier New" class="">func doSomething(localvar: MyProtocol class){</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><span class="Apple-tab-span" style="white-space:pre"><font face="Courier New" class="">        </font></span></div><div class=""><font face="Courier New" class="">}</font></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">In fact, if it will be constrained that way in other situations:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class=""><div class=""><div class="bloop_original_html" style="font-family: Helvetica, Arial; font-size: 13px; background-color: rgb(254, 254, 254);"><blockquote type="cite" class="clean_bq" style="margin: 15px 0px;"><span class="" style="margin-top: 0px; margin-bottom: 0px;"><div dir="auto" class=""><div class=""><blockquote type="cite" class="" style="margin: 15px 0px;"><div class="" style="margin-top: 0px; margin-bottom: 0px;"><div class=""><blockquote type="cite" class="" style="margin: 15px 0px;"><div class="" style="margin-bottom: 0px;"><span class="" style="font-family: Helvetica; font-size: 12px; float: none; display: inline !important;">protocol Foo { typealias T: class }</span><br class="" style="font-family: Helvetica; font-size: 12px;"><br class="" style="font-family: Helvetica; font-size: 12px;"><span class="" style="font-family: Helvetica; font-size: 12px; float: none; display: inline !important;">func foo&lt;T: class&gt;(x: T)</span></div></blockquote></div></div></blockquote></div></div></span></blockquote></div></div></blockquote></div></div></blockquote><br class=""></div><div class="">I understant T can also be a protocol no only a concrete implementation, a class.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">In that way, and it’s another branch to talk about, perhaps it is desirable to constrain method parameters to more than one protocol at a time.&nbsp;</div><div class=""><br class=""></div><div class=""><div class=""><font face="Courier New" class="">func doSomething(localvar: MyProtocol Equatable){</font></div><div class=""><font face="Courier New" class=""><br class=""></font></div><div class=""><span class="Apple-tab-span" style="white-space: pre;"><font face="Courier New" class="">        </font></span></div><div class=""><font face="Courier New" class="">}</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">El 8 des 2015, a les 10:56, Felix Gabel via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; va escriure:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I can only think of one use case for restricting a protocol to be only conformable by structs or enums and that is their special behavior for 'willSet’ and ‘didSet’. But this is already discussed in another thread.&nbsp;</div><div class=""><br class=""></div><div class="">It boils down to this: The sole purpose for a class protocol is its memory management semantics.</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 8, 2015, at 7:43 AM, 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 class="bloop_markdown" 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; background-color: rgb(254, 254, 254);"><p style="margin: 15px 0px; -webkit-margin-before: 0px;" class="">Lets say (and hope) in some future we’ll be able to write functions like this:</p><pre style="margin: 15px 0px; font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 4px 8px; word-break: normal; word-wrap: normal;" class=""><code class="swift" style="font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 0px; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal; -webkit-margin-before: 0px;">func foo&lt;T: class&gt;(_: T) { /* do something */ }
func foo&lt;T: enum&gt;(_: T) { /* do something */ }
func foo&lt;T: struct&gt;(_: T) { /* do something */ }

// or we might want to have more than one generic types

func foo&lt;A: class, B: enum, C: struct&gt;(_: A, _: B, _: C) {
    // do something better
}

// try to use `where` clause with `class A`, `struct C`. It looks ugly to me.
</code></pre><p style="margin: 15px 0px;" class="">So ins’t it better to stick to the original syntax and write code like this!?</p><pre style="margin: 15px 0px; font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 4px 8px; word-break: normal; word-wrap: normal;" class=""><code class="swift" style="font-family: Menlo, Consolas, 'Liberation Mono', Courier, monospace; font-size: 10pt; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(248, 248, 248); color: inherit; border: 0px; margin: 0px; padding: 0px; word-break: normal; word-wrap: normal; -webkit-margin-before: 0px;">protocol MagicType {} // can be applied to any type
protocol ClassType: class {} // only for classes
protocol StructType: struct {} only for structs
protocol ValueType: struct, enum {}  
protocol MixedType: struct, class {}
</code></pre><p style="margin: 15px 0px;" class="">This is why in my eyes the current syntax for protocols is just perfect.</p><div style="margin: 15px 0px;" class=""><br class="webkit-block-placeholder"></div></div><div class="bloop_original_html" 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; background-color: rgb(254, 254, 254);"><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><br class=""><div id="bloop_sign_1449556337510558208" class="bloop_sign"><div class=""><font face="helvetica, arial" class="">—&nbsp;</font></div><div class="">Regards Adrian<br class=""></div></div><br class=""><p class="airmail_on" style="margin: 15px 0px;">Am 7. Dezember 2015 bei 23:29:34, Felix Gabel via swift-evolution (<a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">swift-evolution@swift.org</a>) schrieb:</p><blockquote type="cite" class="clean_bq" style="margin: 15px 0px;"><span style="margin-top: 0px; margin-bottom: 0px;" class=""><div dir="auto" class=""><div class=""></div><div class=""><div class="">Great to hear about being able to apply this to type parameters and associated types in the future. But I still propose to rethink the syntax decision.&nbsp;</div><div class="">&nbsp;</div><div class="">class protocol FooType {}</div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">typealias class Bar: FooType</span></div><div class="">func foo&lt;class T&gt;()</div><div class=""><br class=""></div><div class="">This is more consistent with for example the declaration of a class or property</div><div class=""><br class=""></div><div class="">Construct name: Type</div><div class=""><br class="">On 07 Dec 2015, at 23:04, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" style="margin: 15px 0px;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""><div class=""><blockquote type="cite" class="" style="margin: 15px 0px;"><div class="" style="margin-top: 0px;">On Dec 7, 2015, at 8:58 AM, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="" style="margin-bottom: 0px;"><blockquote type="cite" class="" style="margin: 15px 0px; font-family: Helvetica; font-size: 12px; 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;"><br class="Apple-interchange-newline" style="margin-top: 0px;">On Dec 7, 2015, at 8:00 AM, Matthew Cheok via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">Currently, we declare class protocols with the following syntax:<br class=""><br class="">protocol TestProtocol: class, OtherProtocol {}<br class=""><br class="">This is odd for a few reasons:<br class="">1) The keyword class exists in the middle of the declaration<br class="">2) The keyword class follows the colon and looks a lot like inheritance<br class="">3) The keyword class occupies a somewhat arbitrary first position after the colon (otherwise we have an error)<br class=""><br class="">We also have another use of the class keyword as a modifier when declaring class methods:<br class=""><br class="">class func doSomething() {}<br class=""><br class="">I’m suggesting a change of syntax that rectifies the above issues:<br class=""><br class="">class protocol TestProtocol: OtherProtocol {}<br class=""><br class="">Would love to hear other thoughts on this.<br class="" style="margin-bottom: 0px;"></blockquote><br class="" style="font-family: Helvetica; font-size: 12px; 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="" style="font-family: Helvetica; font-size: 12px; 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;">The constraint syntax is used because, in the fullness of time, it should also be applicable to type parameters and associated types:</span><br class="" style="font-family: Helvetica; font-size: 12px; 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;"><br class="" style="font-family: Helvetica; font-size: 12px; 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="" style="font-family: Helvetica; font-size: 12px; 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;">protocol Foo { typealias T: class }</span><br class="" style="font-family: Helvetica; font-size: 12px; 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;"><br class="" style="font-family: Helvetica; font-size: 12px; 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="" style="font-family: Helvetica; font-size: 12px; 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;">func foo&lt;T: class&gt;(x: T)</span><br class="" style="font-family: Helvetica; font-size: 12px; 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></blockquote></div><div class=""><br class=""></div>Right. This is exactly the reason why we have the syntax<div class=""><br class=""></div><div class="">protocol X : class { … }</div><div class=""><br class=""></div><div class="">and why I’m against changing the current syntax.<br class=""><div class=""><br class=""></div><div class="">- Doug</div><div class=""><br class=""></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=T04LrBojaExXAX0mv-2F2MMtIB9rMFpWjvqf12Pj37IVIQdiJlhqFhPxhoW4X9vomSq4Lb8BPtoy6tsuc7Z-2FPfx-2BPnEHHWg0PcA8l4PIB-2F2Tu4Sm58e8H9F64Tlul3U6zKJIQnbgFKBUujC6Lj6DT2qdu4jJqfeKhy9BF09qIXjUHsc9n6guEjf8v67cSuw8GELmpZv-2Ba0USWU6sLApSSqTQwTDz7dsrYe8pXSYOTqomg-3D" alt="" width="1" height="1" border="0" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""></div></blockquote><blockquote type="cite" style="margin: 15px 0px;" class=""><div style="margin-top: 0px; margin-bottom: 0px;" class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Q0Y0L54uOhrrHtFzGFlMm5JlViMSyhb7WcyBhJqdl-2FFH6e1qNDZ1tyPWzOlZwbqkDLO-2F-2FkeOmNe-2FtqvJvzPKmbLXrZs4XYwWPIzVPHouvezfzkWhzcMo8cEEM5fXJpkruzDQwbRYFGDTf6PynhUnWGfXbsntOCtFF4sGzjwOtjuhrf352Qksog8eifkMyaDjN9xtx4KEN9z5Tll2Y9Hf0-2BrPN9foPSQGgF3ctqGVF94-3D" alt="" width="1" height="1" border="0" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></div></span></blockquote></div><div class="bloop_markdown" 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; background-color: rgb(254, 254, 254);"><div style="margin: 15px 0px; -webkit-margin-before: 0px;" class=""><br class="webkit-block-placeholder"></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=T04LrBojaExXAX0mv-2F2MMtIB9rMFpWjvqf12Pj37IVLnqGWmIbPCuhtxgu-2FEzLILQY4DPZQ1EYg4uKCJNx7LCs5hxySvzfpCw-2BWPON7Jfc7Mz5uqoJGDhi64fNKj21ZnCEOVJspeU7lI0GVsOT4XyuqGaElrnob8a-2BLIFfitwlREMmw4TzbSFd6s-2BwzLO-2BIwY-2Bpsbgao3-2Blln4CW5qzGJDwsoxCQcr-2Brx-2BrCTNG3Rtk-3D" alt="" width="1" height="1" border="0" 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; background-color: rgb(254, 254, 254); height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" 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; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</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; background-color: rgb(254, 254, 254);" 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; background-color: rgb(254, 254, 254); 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; background-color: rgb(254, 254, 254);" class=""><a href="mailto:swift-evolution@swift.org" style="color: rgb(65, 131, 196); background-color: rgb(254, 254, 254); text-decoration: none; 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; background-color: rgb(254, 254, 254);" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="color: rgb(65, 131, 196); background-color: rgb(254, 254, 254); text-decoration: none; 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><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; background-color: rgb(254, 254, 254);" class=""></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHW0kAjxqiRekfpEJArOEyypwILNX2v70x7JAm4tpeLDkemh8xreAuiU0-2F3CVR8fJh2MWMqmcJK7p8F-2F9QP-2BUk9o198pHdjehWzr6l99l3Xn8Rvmgd8f7NbNWhUsz6uomF1qk-2B7TelRMinP7TvuXtFTgxS-2BxDBijTTTeO34V-2FqupDi9d2WROO340tmGM13VvC4w-3D-3D" alt="" width="1" height="1" border="0" style="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;" class="">
</div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></div></div></body></html>