[swift-evolution] Fixing raw enum types

Anton Zhilin antonyzhilin at gmail.com
Tue Jan 17 15:12:31 CST 2017


2017-01-17 22:26 GMT+03:00 Joe Groff <jgroff at apple.com>:

> 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 { ... }
>
>
We don't have this conformance syntax either. As the enum is not generic,
the above should be read as:

    enum Something: (RawRepresentable where RawValue == Int32) { ... }

And this requires generalized existentials again.

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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170118/bab2e8f0/attachment.html>


More information about the swift-evolution mailing list