Serialization library candidate review request

GrimMaple grimmaple95 at gmail.com
Mon Aug 28 18:50:54 UTC 2023


On Monday, 28 August 2023 at 18:27:10 UTC, bauss wrote:
> What if you want to serialize types that are from other 
> libraries, you are forced to copy the structures yourself in 
> order to serialize.
>
> Where as serialization by default lets you just serialize the 
> types regardless.
>
> Your approach only works with your own types, not types from 
> anywhere else, so serializing types from other libraries etc. 
> is going to be tedious.

Not every type is serializable by default, like with my File 
example above. Yes, this won't work with external libraries 
because external libraries aren't designed to have serializable 
structs. However, adding custom serializators to unsupported 
types can be easy via getter serialization, eg:

```d
struct A
{
     Unsupported a;
     @serializable("a") Supported b() { /* magic */ }
}
```

Before you can serialize something, you need to define rules on 
how serialization is going to be performed. If a type wasn't 
designed to be serializable (and you can't really prove if it 
was), then serializing that is going to produce garbage anyway.


More information about the Digitalmars-d mailing list