August 21, 2013
On Thursday, 15 August 2013 at 07:07:13 UTC, Jacob Carlborg wrote:
> On 2013-08-14 21:55, ilya-stromberg wrote:
>
>> Can you use another serialization format and supports file output for
>> it? For example, can you use JSON, BSON or binary format?
>
> The idea of the library is that it can support multiple archive types. Currently only XML is implemented. I have been working on a binary archive for a while but I haven't finished it yet.

Jacob, do you close to finish the work on the binary archive?
August 21, 2013
On 2013-08-21 16:39, ilya-stromberg wrote:

> Jacob, do you close to finish the work on the binary archive?

No, I don't think so.

-- 
/Jacob Carlborg
August 22, 2013
On Sunday, 18 August 2013 at 19:46:00 UTC, Jacob Carlborg wrote:
> If versioning is crucial it can be added.

Can std.serialization load data if class definition was changed?

For example, we have class "Foo":

class Foo
{
    int a;
    int b;
}

and we serialize it in some file. After that class "Foo" was changed:

class Foo
{
    int b;
    int a;
}

Can std.serialization load data from old file to the new class?
August 22, 2013
On 2013-08-22 13:57, ilya-stromberg wrote:

> Can std.serialization load data if class definition was changed?
>
> For example, we have class "Foo":
>
> class Foo
> {
>      int a;
>      int b;
> }
>
> and we serialize it in some file. After that class "Foo" was changed:
>
> class Foo
> {
>      int b;
>      int a;
> }
>
> Can std.serialization load data from old file to the new class?

Yes. In this case it will use the name of the instance fields when searching for values in the archive.

-- 
/Jacob Carlborg
August 22, 2013
On 2013-08-20 20:04, Walter Bright wrote:

> Hmm. That looks then like a ddoc bug.

Added as: http://d.puremagic.com/issues/show_bug.cgi?id=10870
Found this as well: http://d.puremagic.com/issues/show_bug.cgi?id=10869

-- 
/Jacob Carlborg
August 22, 2013
On Thursday, 22 August 2013 at 13:13:48 UTC, Jacob Carlborg wrote:
> On 2013-08-22 13:57, ilya-stromberg wrote:
>
>> Can std.serialization load data if class definition was changed?
> Yes. In this case it will use the name of the instance fields when searching for values in the archive.

Great! What about more difficult cases? For example, we have:

class Foo
{
   int a;
   int b;
}

After changes we have new class:

class Foo
{
   long b;
}

Can std.serialization load data to new class from old file? It should ignore "a" and convert "b" from int to long.
August 22, 2013
On 8/22/2013 9:31 AM, Jacob Carlborg wrote:
> Added as: http://d.puremagic.com/issues/show_bug.cgi?id=10870
> Found this as well: http://d.puremagic.com/issues/show_bug.cgi?id=10869

Thanks

August 22, 2013
On 2013-08-22 21:30, ilya-stromberg wrote:

> Great! What about more difficult cases? For example, we have:
>
> class Foo
> {
>     int a;
>     int b;
> }
>
> After changes we have new class:
>
> class Foo
> {
>     long b;
> }
>
> Can std.serialization load data to new class from old file? It should
> ignore "a" and convert "b" from int to long.

No it can't. It will throw an exception because it cannot find a "long" element:

Could not find an element "long" with the attribute "key" with the value "b"

-- 
/Jacob Carlborg
August 23, 2013
On Thursday, 22 August 2013 at 19:53:53 UTC, Jacob Carlborg wrote:
> On 2013-08-22 21:30, ilya-stromberg wrote:
>
>> What about more difficult cases?
>
> No it can't. It will throw an exception because it cannot find a "long" element:
>
> Could not find an element "long" with the attribute "key" with the value "b"

It's a serious issue. May be it's more important than range support. For example, I have to change class (bug fixing, new features, etc.), but it comparable with previos version (example: it's always possible to convert "int" to "long"). I that case I can't use std.serialization and have to write own solution (for examle, save data in csv file).

The easist way to fix it - store Interface Definition of the serialized data (should be generated automaticly). For example, we can use XML Schema for Xml Archive. With Interface Definition we can find changes and try to convert data to new format.

Note that glycerine also put your attention to this point:
http://forum.dlang.org/post/kftlfwcyughhghewqogm@forum.dlang.org

> 1. Interface Definition Language (IDL): required or not? If not, how do know the details of what to serialize. If not, how do you handle/support data versioning? If not, how do you interoperate without another language? If yes, which types are supported and what is the syntax and grammar of the IDL?

Ideas?
August 23, 2013
On Friday, 23 August 2013 at 13:34:04 UTC, ilya-stromberg wrote:
> It's a serious issue. May be it's more important than range support. For example, I have to change class (bug fixing, new features, etc.), but it comparable with previos version (example: it's always possible to convert "int" to "long"). I that case I can't use std.serialization and have to write own solution (for examle, save data in csv file).

I don't think it as an issue at all. Behavior you want can't be defined in a generic way, at least not without lot of UDA help or similar declarative approach. In other words, the fact that those two classes are interchangeable in the context of the serialization exists only in the mind of programmer, not in D type system.

More than that, such behavior goes seriously out of the line of D being strongly typed language. I think functionality you want does belong to a more specialized module, not generic std.serialization - maybe even format-specific.