Range interface for std.serialization

Jacob Carlborg doob at me.com
Wed Aug 28 11:31:17 PDT 2013


On 2013-08-28 11:58, Dmitry Olshansky wrote:

> That would be tricky in JSON and quite overheadish (e.g. wrapping
> everything into object just in case there is a pointer there).

Yes.

> Yes, instead of cheating you can just define them as different kinds. It
> would ease the friction and prevent some "impedance mismatch" problems.

Yes, that's better.

> Then collect some info on how to approach this problem.
> See e.g. Boost serialziation, Protocol Buffers and Thrift.
> The key point is that it's many things to many different people.

I'll do that.

> Rather this:
>
> void toData(Serializer)(Serializer serializer)
>      if(isSerializer!Serializer)
> {
>      ...
> }
>
> There is no need to even know how archiver looks like for the user code
> (wasn't it one of the goals of archivers?).

Right, didn't think of using a template argument for the whole serializer.


> Serializers themselves on the other hand are present in user code and
> may need one common polymorphic abstract class that provides 'put' and
> forwards it to a set of abstract methods. All polymorphic wrappers would
> inherit from it.
>
> This won't prevent folks from using templated version of toData/fromData
> if need be.

That's a good idea.

> I'd suggest to maximally hide away (Un)Archivers API from end users and
> as such it would be more convenient to just stay templated as it won't
> be seen.

Yes.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list