std.serialization
Jacob Carlborg
doob at me.com
Sun Feb 16 12:16:34 PST 2014
On 2014-02-16 18:52, Orvid King wrote:
> Slices are handled as arrays, because of the fact that they need to be
> handled in such a way that many different types of serialization formats
> can support them, and be inter-operable with implementations in
> languages other than D.
>
> Pointers are not supported, because in my opinion, they should _NEVER_
> be serialized.
Why not? Think of languages like C and C++, they only support pointers.
Pointers to basic types are not so interesting but pointers to structs are.
> Reference types are serialized as they are encountered, I haven't
> handled the circular reference case yet.
If the same reference value is encountered multiple times, is it
serialized once or multiple times?
> Events are not supported due to the fact it would require complete
> knowledge of the source and target environments of the serialization.
What? I'm referring to methods being called before and after
serialization of a given value.
> Custom serialization is supported by either supporting
> to!YourType(string) or YourType.parse(string) /
> to!string(valueOfYourType) or valueOfYourType.toString(), and are
> handled transparently by the base serialization handler, the actual
> serialization format sees them simply as strings. Each serialization
> format however does have the ability to select any type it wants to
> support being serialized.
>
> And third party types are only supported if they have the requisite UDA,
> or support custom serialization.
>
>> Why require a UDA?
> The UDA is required for the exact same reason it's required in the .net
> framework, because it makes sure that the type you are trying to
> serialize is serialization aware, meaning that it's not serializing
> cache fields, and also makes sense to actually be serializing the type.
I prefer opt-out rather than opt-in.
Can it serialize through base class references?
--
/Jacob Carlborg
More information about the Digitalmars-d-announce
mailing list