<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 17, 2017, at 9:54 AM, Anton Zhilin via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important" class="">Some criticism for all the mentioned variants:</p><p style="margin:0px 0px 1.2em!important" class=""><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="">enum Something : raw(Int32)</code><br class="">Requires adding a new contextual keyword.</p><p style="margin:0px 0px 1.2em!important" class=""><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="">enum Something : RawRepresentable</code><br class="">With additional <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="">typealias RawValue</code>, the simplest cases will lose their elegancy.</p><p style="margin:0px 0px 1.2em!important" class=""><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="">enum Something : RawRepresentable<Int32></code><br class="">+1. But we don’t have generic protocols right now :(</p></div></div></div></blockquote><div>I think this would be the right direction to go if we wanted to de-magic the existing RawRepresentable behavior. At this point, It would be reasonable to support this via where clauses on associated types:</div><div><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><div>enum Something: RawRepresentable where RawValue == Int32 { ... }</div></div></blockquote><div><div><br class=""></div><div>though that's pretty verbose. In the fullness of time, a generic typealias to a generalized existential could help with that, though:</div><div><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><div>typealias RawRepresentableOf<T> = RawRepresentable where RawValue == T</div></div></blockquote><div class=""><br class=""></div><div class="">At that point, the compiler-built becomes closer to just a "regular" default implementation. There's still the privileged sugar for matching cases to raw values.</div><br class=""><div>-Joe</div><div><br class=""></div></body></html>