std.serialization: pre-voting review / discussion

ilya-stromberg ilya-stromberg-2009 at yandex.ru
Mon Aug 26 10:04:29 PDT 2013


On Saturday, 24 August 2013 at 17:47:35 UTC, Jacob Carlborg wrote:
> 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.

The name "isSerializable" is TERRIBLE:
https://dl.dropboxusercontent.com/u/18386187/docs/std.serialization/std_serialization_serializable.html#.isSerializable
It only checks if functions "toData" and "fromData" exists in a 
class or struct. But std.serialization can serialize almost any 
data, so please rename the template, like 
"hasCustomSerialization".

The real "isSerializable" must check if it's possible to 
serialize and should look like this:
enum isSerializable(T) = serializer.serialize(T);


More information about the Digitalmars-d mailing list