Time to kill T() as (sometimes) working T.init alias ?

Walter Bright newshound2 at digitalmars.com
Wed Nov 28 19:24:38 PST 2012


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/bvuquzwfykiytdwsqkky@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.


More information about the Digitalmars-d mailing list