[swift-evolution] [Proposal] Foundation Swift Archival & Serialization

Zach Waldowski zach at waldowski.me
Thu Mar 16 10:53:19 CDT 2017


> On Mar 16, 2017, at 3:09 AM, David Hart via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 2) Libraries like Marshal (https://github.com/utahiosmac/Marshal <https://github.com/utahiosmac/Marshal>) and Unbox (https://github.com/JohnSundell/Unbox <https://github.com/JohnSundell/Unbox>) don’t require the decoding functions to provide the type: those functions are generic on the return turn and it’s automatically inferred:
> 
> func decode<T>(key: Key) -> T
> 
> self.stringProperty = decode(key: .stringProperty) // correct specialisation of the generic function chosen by the compiler
> 
> Is there a reason the proposal did not choose this solution? Its quite sweet.

IMHO those are only “sweet” until you need to decode a value out to something other than a typed value, then it’s ambiguity city. There are many ways to solve that, but none of them are conducive to beginners. Using the metatype to seed the generic resolution is the only thing I’d get behind, personally.

Zach Waldowski
zach at waldowski.me

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170316/0c18a567/attachment.html>


More information about the swift-evolution mailing list