No, I don't think so. How would you declare a variable of type X, meaning the protocol?<br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 23, 2017 at 19:49 Jonathan Hull <<a href="mailto:jhull@gbis.com">jhull@gbis.com</a>> 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" class="gmail_msg">I agree with your point on classes, so maybe just value types would be allowed to do it (I have only wanted it for structs myself). I think I answered your comment about distinguishing between existential and struct X if you re-read my original message.<div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Thanks,</div><div class="gmail_msg">Jon</div></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 23, 2017, at 5:10 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>> wrote:</div><br class="m_-7740034557234795946Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg">This would get very confusing, as it would be impossible for a class to distinguish conforming to protocol X vs. inheriting from base class X, or else we would have to change the spelling for that as well. Moreover, you would have no way of distinguishing the existential X from the struct X. I see nothing wrong with the clarity afforded by naming the distinct things `FooProtocol` and `Foo`, and I disagree that there's anything "simplifying" about naming two different things with one name.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Mon, Jan 23, 2017 at 6:13 PM, Jonathan Hull via swift-evolution <span dir="ltr" class="gmail_msg"><<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Have we considered allowing a struct/class/enum to have the same name as a protocol as long as it conforms to the protocol? Type declarations would have to always mean the protocol (which includes the concrete type as well). Static functions would always apply to the concrete type.<br class="gmail_msg">
<br class="gmail_msg">
Seems like a good way to support having a default implementation of a protocol. I am always running into the awkward naming issues around this...<br class="gmail_msg">
<br class="gmail_msg">
protocol X {<br class="gmail_msg">
//yada yada<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
struct X { //Implicitly adheres to protocol X (because it must)<br class="gmail_msg">
init(){…}<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
let myVar:X //This refers to the protocol<br class="gmail_msg">
let otherVar = X() //This makes the struct<br class="gmail_msg">
<br class="gmail_msg">
If we do need to be able to spell the concrete type for other uses, we could probably do something like: ‘concrete(X)’ which isn’t pretty, but is there for the rare times it is needed for utility. I can’t think of any reason except making an array of the concrete type.<br class="gmail_msg">
<br class="gmail_msg">
I am guessing there is a subtle technical reason this won’t work, but I wanted to mention it now just in case it is possible. Seems like it could have a large (simplifying) effect on the namespace of the standard library.<br class="gmail_msg">
<br class="gmail_msg">
Thanks,<br class="gmail_msg">
Jon<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div><br class="gmail_msg"></div></div>
</div></blockquote></div><br class="gmail_msg"></div></div></div></div></blockquote></div>