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

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 8 12:37:44 PDT 2016


On Thursday, 8 September 2016 at 10:06:16 UTC, John Colvin wrote:
> I think it's too late for this stuff now for D anyway. There 
> are workarounds that make life acceptable without default 
> constructors, I can't see how we could add them without getting 
> into a real mess.

The kind of flow analysis required to ensure something is 
constructed before use is roughly the same as the one required to 
do non nullable reference and/or lifetime analysis (in fact that 
last one require a superset of what is required for the first 2).

If adding it simply for the default constructor is probably 
hitting the wrong tradeof in term of bang for the buck, adding to 
get the 3 above seems like it would be worth it.

As s side note, this is why I think issue based language 
discussion is not a good way to proceed, as we are missing the 
kind of bigger picture insight as this one. When going issue 
based we are like, "Do we want to add this for default ctors ? 
No, it doesn't pay for itself." Then later on "Do we want to add 
this for non nullable references ? No, it doesn't pay for 
itself." and so, whereas the rational question would be "Do we 
want to add this for default ctors, non nullable references and 
lifetime analysis ? Well now, probably yes." Thing is, 
considering each question individually wouldn't yield the best 
choice.



More information about the Digitalmars-d mailing list