<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Now is still the time for source breaking changes if well motivated, when dealing with key aspects of the language and we can make them objectively better then we ought to act when we can I think.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">+1<br><br>Sent from my iPhone</div><div><br>On 17 Jan 2017, at 06:11, Pranshu Goyal via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Definitely a +1, this clarifies intent, but enums are used a lot in swift code, and considering this is a source breaking change I'm not sure if many users of swift are going to be positive about this.<br><div class="gmail_extra"><br><div class="gmail_quote">On 17 January 2017 at 02:32, David Waite via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Or perhaps paint the bikeshed <div><br></div><div>enum Something<(Int32, Int32)> { … }<div><br></div><div>-DW<br><div><blockquote type="cite"><div><div class="h5"><div>On Jan 16, 2017, at 11:51 AM, Anton Zhilin via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-2802832713784090717Apple-interchange-newline"></div></div><div><div><div class="h5"><div dir="ltr"><div class="m_-2802832713784090717markdown-here-wrapper"><p style="margin:0px 0px 1.2em!important">This idea by Karl made me branch off a new thread.</p><p style="margin:0px 0px 1.2em!important">2017-01-16 21:28 GMT+03:00 Karl Wagner <<a href="mailto:razielim@gmail.com" target="_blank">razielim@gmail.com</a>>:</p><div style="margin:0px 0px 1.2em!important"><br class="m_-2802832713784090717webkit-block-placeholder"></div><div class="m_-2802832713784090717markdown-here-exclude"><div><br class="m_-2802832713784090717webkit-block-placeholder"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div dir="auto" style="word-wrap:break-word"><div>It would be helpful for synthesised RawRep conformance. The inheritance-like syntax we have now is awful - it makes people think that RawRepresentable is some kind of magic protocol that will allow special compiler jango to happen.</div><div><br></div><div>You could see why they think that. This looks very much like the enum is going to *be* an Int32:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="Courier">enum Something: Int32 {</font></div><div><font face="Courier"> case oneThing = 36</font></div><div><font face="Courier"> case anotherThing = 42</font></div><div><font face="Courier">}</font></div><div><font face="Courier"><br></font></div></blockquote>This is also one of the icky parts to allowing tuples of integer/string literals (something people ask for quite a lot). It would look like you’re deriving your enum from a non-nominal type:<div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><font face="Courier">enum Something: (Int32, Int32) {</font></div><div><font face="Courier"> case oneThing = (3, 12)</font></div><div><font face="Courier"> case anotherThing = (5, 9)</font></div><div><font face="Courier">}</font></div></blockquote></div></div></blockquote><div><br class="m_-2802832713784090717webkit-block-placeholder"></div></div><div style="margin:0px 0px 1.2em!important"><br class="m_-2802832713784090717webkit-block-placeholder"></div><p style="margin:0px 0px 1.2em!important">Even if Swift gains <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">newtype</code>, it’s not that case. The enum does not gain methods or behavior of the specified type. It’s just a shorthand, hinting the compiler to provide correct <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">RawRepresentable</code> conformance.</p><p style="margin:0px 0px 1.2em!important">I suggest to invent a new syntax for this type hinting for <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">RawRepresentable</code>. For example, it can be an annotation:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">@raw(Int32) enum Something {
// ...
}
</code></pre><p style="margin:0px 0px 1.2em!important">Or a contextual keyword:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">enum Something : raw(Int32) {
// ...
}
</code></pre><p style="margin:0px 0px 1.2em!important">Perhaps, he most uniform and explicit of syntaxes:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">enum Something : RawRepresentable {
case oneThing = 36
case anotherThing = 42
}
enum AnotherThing : RawRepresentable {
typealias RawValue = Int32
case oneThing
case anotherThing
}
</code></pre><div title="MDH:PGRpdj5UaGlzIGlkZWEgYnkgS2FybCBtYW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ZW51bSBTb21ldGhpbmcgOiByYXcoSW50MzIpIHs8
L2Rpdj48ZGl2PiZuYnNwOyAmbmJzcDsgLy8gLi4uPC9kaXY+PGRpdj59PC9kaXY+PGRpdj5gYGA8
L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PlBlcmhhcHMsIGhlIG1vc3QgdW5pZm9ybSBhbmQgZXhw
bGljaXQgb2Ygc3ludGF4ZXM6PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5gYGA8L2Rpdj48ZGl2
PmVudW0gU29tZXRoaW5nIDogUmF3UmVwcmVzZW50YWJsZSB7PC9kaXY+PGRpdj4mbmJzcDsgJm5i
c3A7IGNhc2Ugb25lVGhpbmcgPSAzNjwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyBjYXNlIGFub3Ro
ZXJUaGluZyA9IDQyPC9kaXY+PGRpdj59PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5lbnVtIEFu
b3RoZXJUaGluZyA6IFJhd1JlcHJlc2VudGFibGUgezwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyB0
eXBlYWxpYXMgUmF3VmFsdWUgPSBJbnQzMjwvZGl2PjxkaXY+Jm5ic3A7ICZuYnNwOyBjYXNlIG9u
ZVRoaW5nPC9kaXY+PGRpdj4mbmJzcDsgJm5ic3A7IGNhc2UgYW5vdGhlclRoaW5nPC9kaXY+PGRp
dj59PC9kaXY+PGRpdj5gYGA8L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div></div></div></div><span class="">
______________________________<wbr>_________________<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" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></span></div></blockquote></div><br></div></div></div><br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><font color="#999999" size="2" face="georgia, serif"><i>Pranshu Goyal</i></font></div></div>
</div></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>