enum Something: RawRepresentable&lt;Int32&gt; {<br><br>}<br><br>Generics?<br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 16, 2017 at 1:51 PM Anton Zhilin 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 dir="ltr" class="gmail_msg"><div class="m_6965946629633574363markdown-here-wrapper gmail_msg"><p style="margin:0px 0px 1.2em!important" class="gmail_msg">This idea by Karl made me branch off a new thread.</p>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg">2017-01-16 21:28 GMT+03:00 Karl Wagner &lt;<a href="mailto:razielim@gmail.com" class="gmail_msg" target="_blank">razielim@gmail.com</a>&gt;:</p>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg"></p><div class="m_6965946629633574363markdown-here-exclude gmail_msg"><p class="gmail_msg"></p><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div dir="auto" style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">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 class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">You could see why they think that. This looks very much like the enum is going to *be* an Int32:</div><div class="gmail_msg"><br class="gmail_msg"></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="gmail_msg"><div class="gmail_msg"><font face="Courier" class="gmail_msg">enum Something: Int32 {</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg">    case oneThing = 36</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg">    case anotherThing = 42</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg">}</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg"><br class="gmail_msg"></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 class="gmail_msg"><br class="gmail_msg"></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="gmail_msg"><div class="gmail_msg"><font face="Courier" class="gmail_msg">enum Something: (Int32, Int32) {</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg">    case oneThing = (3, 12)</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg">    case anotherThing = (5, 9)</font></div><div class="gmail_msg"><font face="Courier" class="gmail_msg">}</font></div></blockquote></div></div></blockquote><p class="gmail_msg"></p></div><p style="margin:0px 0px 1.2em!important" class="gmail_msg"></p>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg">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" class="gmail_msg">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" class="gmail_msg">RawRepresentable</code> conformance.</p>
<p style="margin:0px 0px 1.2em!important" class="gmail_msg">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" class="gmail_msg">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" class="gmail_msg"><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" class="gmail_msg">@raw(Int32) enum Something {
    // ...
}
</code></pre><p style="margin:0px 0px 1.2em!important" class="gmail_msg">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" class="gmail_msg"><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" class="gmail_msg">enum Something : raw(Int32) {
    // ...
}
</code></pre><p style="margin:0px 0px 1.2em!important" class="gmail_msg">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" class="gmail_msg"><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" class="gmail_msg">enum Something : RawRepresentable {
    case oneThing = 36
    case anotherThing = 42
}

enum AnotherThing : RawRepresentable {
    typealias RawValue = Int32
    case oneThing
    case anotherThing
}
</code></pre><div title="MDH:PGRpdj5UaGlzIGlkZWEgYnkgS2FybCBtYWRlIG1lIGJyYW5jaCBvZmYgYSBuZXcgdGhyZWFkLjwv
ZGl2PjxkaXY+PGJyPjwvZGl2PjIwMTctMDEtMTYgMjE6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GRpdj59PC9kaXY+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" class="gmail_msg">​</div></div></div>
_______________________________________________<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>