[swift-evolution] [Proposal] Foundation Swift Archival & Serialization
David Hart
david at hartbit.com
Thu Mar 16 13:06:04 CDT 2017
> On 16 Mar 2017, at 16:53, Zach Waldowski <zach at waldowski.me> wrote:
>
>> 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) and 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.
Other than a typed value? Can you give an example?
> 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/06b93527/attachment.html>
More information about the swift-evolution
mailing list