When D feels unfinished: union initialization and NRVO

Denis Feklushkin feklushkin.denis at gmail.com
Wed Mar 18 07:14:13 UTC 2020


On Wednesday, 18 March 2020 at 06:55:24 UTC, Mathias Lang wrote:
> So I've been toying around for a bit with writing a 
> deserializer in D. It essentially converts types to an array of 
> `ubyte[]` in a very simple way. Handles value types 
> automatically, and pointers / arrays. Nothing too fancy, but I 
> wanted to write something *correct*, and compatible with the 
> types I'm dealing with.
>
> The issue I was faced with is how to handle qualifiers. For 
> example, deserializing `const` or `immutable` data. Originally, 
> my deserializer accepted a `ref T` as parameter and would 
> deserialize into it. I changed it to return an element of type 
> `T`.

IMHO serialization of language level types is the same kind of 
deceiving goal as ORM, "all is object", etc.

If you move to the higher level - serialize objects (in terms of 
your software, not just OOP objects) that you are modeling - this 
problem will gone.



More information about the Digitalmars-d mailing list