Trying to use Mir ion, its a perfect example of the failure of D's attribute system
Steven Schveighoffer
schveiguy at gmail.com
Thu Jan 19 15:22:08 UTC 2023
On 1/18/23 8:51 PM, A moo person wrote:
> This is a semi rant born from frustration. Currently I'm trying to
> figure out Mir Ion so I can serialize some data, and oh boy is it
> frustrating.
>
> The entire library is annotated out the wazoo with @safe and @nogc and
> pure and inout. Its a serialization library so as you might imagine it's
> doing reflection on types, calling member functions to try and serialize
> stuff, things like that. I have spent hours now adding attributes and
> casting attributes away. Writing @trusted wrapper types for std.algo
> ranges. Trying to decipher the vomit that dmd gives when one the types
> is not quite right. All I want to do is serialize a list of structs from
> a range and be able to deserialize them back but I can't do that because
> I still have not gotten it working.
>
> It's actually maddening, I have spent 2 days on this. What value are all
> these attributes adding? Because it's a useability nightmare. Every time
> I encounter a D library that tries to be clever with these annotations,
> it's just absolutely made things more complex and less useable. Same
> story every time I have ever tried to use them in my own code.
Something like serialization/deserialization (which requires templates)
should use attribute inference, and use unittests to prove memory
safety/nogc/etc.
Now, this *can* break down if not explicit since the compiler sometimes
gives up on inference, so maybe that's what happened here.
-Steve
More information about the Digitalmars-d
mailing list