On 2011-10-01 05:00, Robert Jacques wrote:
I agree, which is why I suggested lookup should have some granuality.
i.e. that there is both a global store of serialization methods and a
per instance store of serialization methods. Lookup would first look in
the local store before defaulting to the global store. But this should
be a separate pair of functions.

Aah, now I get it. That's a good idea. The question is what to name the two functions. Yet another use case for overloading methods on static.

I'm sorry, I was thinking about archive types (i.e. JSON vs XML) and
somehow thinking that the Serializers would be different for each. (I
was thinking that the serializer was templated on the archive for some
reason.)

Ok, no problem.

Both

T deserialize (T)();
T deserialize (T)(string key);

have the following example:

class Foo
{
int a;

void fromData (Serializer serializer, Serializer.Data key)
{
a = serializer!(int)("a");
}
}


No, "T deserialize (T)(string key)" has:

a = serializer!(int)("a");

And "T deserialize (T)()" has:

a = serializer!(int)();

Both are correct. This is a complete example of using one of these methods: https://github.com/jacob-carlborg/orange/blob/master/tests/Custom.d

Let me know if anything is confusing.

--
/Jacob Carlborg

Reply via email to