> On Jan 17, 2017, at 9:54 AM, Anton Zhilin via swift-evolution
> <[email protected]> wrote:
>
> Some criticism for all the mentioned variants:
>
> enum Something : raw(Int32)
> Requires adding a new contextual keyword.
>
> enum Something : RawRepresentable
> With additional typealias RawValue, the simplest cases will lose their
> elegancy.
>
> enum Something : RawRepresentable<Int32>
> +1. But we don’t have generic protocols right now :(
>
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:
enum Something: RawRepresentable where RawValue == Int32 { ... }
though that's pretty verbose. In the fullness of time, a generic typealias to a
generalized existential could help with that, though:
typealias RawRepresentableOf<T> = RawRepresentable where RawValue == T
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.
-Joe
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution