[swift-evolution] [Proposal] Foundation Swift Archival & Serialization
anthony.parker at apple.com
Mon Mar 20 12:17:16 CDT 2017
> On Mar 19, 2017, at 9:53 PM, Kenny Leung via swift-evolution <swift-evolution at swift.org> wrote:
> Hi All.
> Forgive me if I missed it - I haven’t read the proposal in full detail - but it seems to make no mention of archiving graphs with circular references. Is this implicitly supported, or explicitly unsupported?
We expect this to be left up to the encoders and decoders. In Foundation itself, we actually have subclasses of NSCoder that support this and subclasses that do not.
> While we’re at it, my only real exposure to archiving is through Foundation, so I’d like to know how everybody else understands these terms:
> serialization - the process of “flattening” out an object graph into a serial stream of objects
> encoding - the process of converting internal object data into an external format
> archiving - the whole enchilada of serialization + encoding
Good question about terminology. Here is how we’ve tried to define these:
Serialization: conversion of a small fixed set of types to a data format and back
ex. NSJSONSerialization, NSPropertyListSerialization
Encoding: conversion of an arbitrary type to a smaller set of serialized types and back
ex: Encoder, Decoder, JSONEncoder, PropertyListEncoder
Archiver: In the ObjC Foundation, the objects which do the encoding. In this proposal we have chosen not to re-use this term to avoid confusion. Instead we tried to simplify the terminology by calling the top level concrete object an encoder.
More information about the swift-evolution