adamdruppe / arsd

This is a collection of modules that I've released over the years. Most of them stand alone, or have just one or two dependencies in here, so you don't have to download this whole repo.
http://arsd-official.dpldocs.info/arsd.html
531 stars 128 forks source link

com.getD: Remove redundant variant logic #444

Closed dkorpel closed 3 months ago

dkorpel commented 3 months ago

Is noticed that getD!string gives a string with an extra '\0' byte appended, because that's apparently how makeUtf8StringFromWindowsString(wchar*) works. I could make it use the same logic as getFromVariant, but then I wondered: why have two special cases for int and string` anyway? Seems like a relic, but correct me if I'm wrong.

adamdruppe commented 3 months ago

I vaguely recall having getD originally intended to do more auto-wrapping and conversions but let me check the history and get back to you.

adamdruppe commented 3 months ago

Finally remembered to look back at this, so yeah the difference is getD does some implicit conversions where getFromVariant is meant to be more strict. kinda like std.variant's get vs coerce.

So like say there's a float in the variant. getD!double would allow that, since you can implicitly convert the double to float. getFromVariant!double would throw about a type mismatch.

I just never actually finished it and anyway, we should be ok checking the tag without duplicating as much logic so let's merge and maybe change the function again later to add useful conversions if they come up.