Structs and classes should offer for introspection each field's default value. That should be available as a string that can be mixed in. For void initialization, the string would naturally be "void".
A simpler alternative would be to just offer an array of immutable bytes that can be used to initialize the object. That is suboptimal because it does not skip void-initialized fields.
This blocks https://github.com/dlang/druntime/pull/3174.
Comment #1 by destructionator — 2020-08-10T01:32:40Z
A string is going to hit trouble with module imports and such. It could possibly be a function though, and a void function represents the void initializer. (hopefully this would be a function the compiler knows it can always ctfe optimize away).
Comment #2 by bugzilla — 2020-08-10T21:53:16Z
The difficulty with a field-by-field initializer is being careful about where the holes go and overlapping fields.
Comment #3 by robert.schadek — 2024-12-13T19:10:45Z