std.serialization: pre-voting review / discussion
Jacob Carlborg
doob at me.com
Sat Aug 24 10:47:35 PDT 2013
On 2013-08-24 14:45, ilya-stromberg wrote:
> Great job!
> A little question. For example, I would like to load data from previos
> format and store current version in default std.serialization format.
> So, I don't want to implement "toData" at all? Is it possible? Or can I
> call the default serialization method? Something like this:
>
> class Foo : Serializable
> {
> long b;
>
> //I don't want to implement this
> void toData (Serializer serializer, Serializer.Data key)
> {
> serializer.serialize(this);
> }
>
> void fromData (Serializer serializer, Serializer.Data key)
> {
> b = serializer.deserialize!(int)("b");
> }
> }
I actually noticed this problem when I wrote the example. First, the
interface Serializable is actually not necessary because this is
actually checked with at template at compile time, it's possible to use
these methods for structs as well. Second, instead of checking for both
"toData" and "fromData" when serializing and deserializing it should
only check for "toData" when serializing and only for "fromData" when
deserializing.
I'll add this to my todo list.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list