std.serialization: pre-voting review / discussion

Jacob Carlborg doob at me.com
Tue Aug 20 12:34:54 PDT 2013


On 2013-08-20 15:12, Dicebot wrote:

> What I really don't like is excessive amount of object in the API. For
> example, I have found no reason why I need to create serializer object
> to simply dump a struct state. It is both boilerplate and runtime
> overhead I can't justify. Only state serializer has is archiver - and it
> is simply collection of methods on its own. I prefer to be able to do
> something like `auto data = serialize!XmlArchiver(value);`

I have been planning to add a function like that but just haven't got 
around doing it. This is just a convenience function that is easy to add.

Some reasons for having an object oriented API are:

* The serializer does have state. It stores information about what's 
serialized and keep track that an object is not stored more than once in 
the archive and similar things.

* When doing custom serialization the serializer is passed to the 
methods: https://github.com/jacob-carlborg/orange/wiki/Custom-Serialization

> I have found documentation complete enough to get a basic understanding
> personally but one thing that has caused some frustration is that docs
> don't make clear distinction between minimal stuff and extra features.
> For example, there is
> https://dl.dropboxusercontent.com/u/18386187/docs/std.serialization/std_serialization_serializable.html
> - my guess that it is only used if user wants to override default
> serialization method for an aggregate type. But documentation for it is
> written in such manner that it gives an impression that it is absolutely
> required.

Ok, I can try and clarify that.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list