Structs are Not Plain: A call for empty struct constructors

Ethan gooberman at
Thu Sep 19 15:08:43 UTC 2019

On Thursday, 19 September 2019 at 09:02:39 UTC, FeepingCreature 
> I think the deeper problem stems right from the original 
> assumption that structs are "plain old data" and thus shouldn't 
> be interested in construction.

I've made this point many times over the years with regards to 
C++ binding. One of my DConf talks explicitly points out that 
making a Mutex/CriticalSection object cannot be initialised with 
a postblit. I think I even pointed out the static opCall hack as 
well in that talk... but I disagree with it because the meaning 
is different between C++ and D (C++ -> zero initialisation; D -> 
call a function that isn't a constructor of any kind).

Whenever someone says "RAII doesn't work in D" it's because 
struct default constructors are disallowed.

More information about the Digitalmars-d mailing list