== Quote from Walter Bright (newshou...@digitalmars.com)'s article > Jonathan M Davis wrote: > > How hard would it really be to insert code wherever a struct's init value is > > used to default construct it either when the program starts up (for > > globals) or > > right after it's declared (for locals)? If you could do that, then I don't > > see > > why we couldn't have proper default constructors. All I can assume is that > > adding that extra code to default construct structs would be painful change > > to > > make to dmd, but perhaps there's something else that I'm missing. If that > > could > > be done though, it would be a _huge_ improvement. > There are some severe problems with that approach. One of the largest is the > possibility that the default constructor may fail (throw an exception). This > has > a vast impact on the design of things, and wrecks a lot of generic code that > relies on being able to guarantee initialization success.
While I'm also skeptical of the idea that simply declaring a variable can cause arbitrarily complex code to be executed, I'll play Devil's Advocate a little: What if we required the default struct constructor to be nothrow? We could also require some level of purity (at least weak pure).