Request for pre-review: std.serialization/orange

Robert Jacques sandford at jhu.edu
Fri Sep 30 06:03:02 PDT 2011


On Thu, 29 Sep 2011 14:58:30 -0400, Jacob Carlborg <doob at me.com> wrote:
> I would like to have some form of pre-review of my serialization library
> Orange for later inclusion in Phobos as std.serialization (or similar).

[snip]

This is a quick note on the API design; I'm planning on doing a deeper review of the code + API later.

Re: registerSerializer
Type.stringof is not unique and can't be used by your serializer. Furthermore, allowing users to manually set the lookup string is going to be a major source of silent errors / bugs and exposes a large portions of your internals. Doing it in this way prevents you from updating how the back-end looks up types.

I'd recommend using: typeid(A).toString internally instead as this is unique and registerSerializer's API to

void registerSerializer(Derived,Base)(void delegate(Base) dg) if( is(Derived:Base) ) {}

which would be called via:

registerSerializer!Foo(dg);


The method should also be static: If I'm registering a custom serialization method, I don't want to duplicate that mapping everywhere a serializer is instanced. I don't even want to duplicate it for every type of serializer. I think there needs to be some granularity for this: i.e. instance -> type -> global.

Also, repeat the above for registerDeserializer.


Re: deserialize some of the example don't look like they're correct.


More information about the Digitalmars-d mailing list