[swift-evolution] [Review] SE-0167: Swift Encoders

Jordan Rose jordan_rose at apple.com
Mon Apr 10 16:26:48 CDT 2017


[Proposal: https://github.com/apple/swift-evolution/blob/master/proposals/0167-swift-encoders.md <https://github.com/apple/swift-evolution/blob/master/proposals/0167-swift-encoders.md>]

There's some pretty cool stuff in here. Nice work. I do have a few questions about this design, though:

- Why are the encoders and decoders open classes? (In particular, the fixed set of "strategies" seems like it'll be a problem if we plan to keep adding cases.) For that matter, why make them classes at all?

- I don't understand 'DateEncodingStrategy.deferredToDate'. It seems like this will always match one of the other cases in practice, and it isn't safe for any stable encoding.

- I assume you've thought about this, but there's no way for existing Cocoa types to conform to Decodable, since it introduces a new required initializer.* The design here doesn't rely on that at all, but I feel like it's worth calling out explicitly.


* Why does Decodable introduce a required initializer? Because when a class conforms to a protocol, it's declaring that it and all its subclasses conform to the protocol. But since initializers are not automatically inherited in Swift, there's no way to add new initializers to all existing subclasses.

Jordan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170410/7d0e6c54/attachment.html>


More information about the swift-evolution mailing list