Struct default constructor - need some kind of solution for C++ interop

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 7 15:24:31 PDT 2016


On Wednesday, 7 September 2016 at 21:05:32 UTC, Walter Bright 
wrote:
> The reasons D structs don't have a default constructor:
>
> 1. So S.init is a valid initializer
> 2. So all instances of S can be guaranteed to contain a valid 
> instance
> 3. So default initialization is guaranteed to succeed
> 4. So any struct constructor starts with a valid state
> 5. In my not-so-humble opinion, construction should never fail 
> and all constructors should be nothrow, but I understand that 
> is a minority viewpoint
>
> Assumptions 1..4 are pervasive in D and the logic of the 
> compiler.

What, precisely, does "valid" mean in the above?


More information about the Digitalmars-d mailing list