[swift-evolution] Could enums have their rawValue type inferred?

Austin Zheng austinzheng at gmail.com
Tue May 17 15:08:19 CDT 2016


Oh, this is a really interesting use case for that protocol. I wonder if
RawRepresentable might one day be auto-derivable for certain types, as part
of a more comprehensive Swift serialization/deserialization feature.

Austin

On Tue, May 17, 2016 at 1:05 PM, Brent Royal-Gordon via swift-evolution <
swift-evolution at swift.org> wrote:

> > On the other hand: What's the point of "raw-value enums"? Are they just
> a bridge-technogy, or is it ok to use them to store constants?
>
> I think of RawRepresentable (the protocol behind rawValue) as a
> serialization mechanism, basically the Swift standard library's answer to
> NSCoding. Thus, rawValue is a way to serialize your enum into an Int or
> String you know how to read and write from disk. More broadly, I often
> apply RawRepresentable to structs and have them return plist- or
> JSON-compatible dictionaries.
>
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160517/2885e0ba/attachment.html>


More information about the swift-evolution mailing list