On Thursday, November 29, 2012 14:24:38 Walter Bright wrote: > On 11/29/2012 4:47 AM, monarch_dodra wrote: > > On Sunday, 25 November 2012 at 16:47:08 UTC, Dmitry Olshansky wrote: > >> Thoughts? > > > > I don't know about "killing" T(), but I think there *needs* to be an > > (easy) mechanism to declare ***and*** run-time initialize an object, in > > a single and comprehensive line. > > > > I had proposed something 2 months ago here: > > http://forum.dlang.org/thread/bvuquzwfykiytdwsq...@forum.dlang.org > > > > The proposal wasn't perfect, but still. We need to figure something out... > > The original idea is that there should be *no such thing* as default > construction of a struct as being anything other than T.init. The > default construction of a struct should be a compile time creature, not > a runtime one. > > Any methods or workarounds to try and make T() produce something > different from T.init is bad D practice. The compiler tries to > statically head them off, but probably should do a better job of that.
I believe that it's very common practice in D to use static opCall to effectively give structs a default constructor when one is desired. I don't think that we need to try and add any default construction mechanism beyond that and that init is sufficient for most cases, but I don't see any reason why using static opCall for providing something closer to a default constructor would be a bad idea, and your post seems to indicate that you think that it is. - Jonathan M Davis