Scott Meyers' DConf 2014 keynote "The Last Thing D Needs"

Steven Schveighoffer via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu May 29 10:54:54 PDT 2014


On Thu, 29 May 2014 13:12:24 -0400, Walter Bright  
<newshound2 at digitalmars.com> wrote:

> On 5/29/2014 6:11 AM, Steven Schveighoffer wrote:
>> struct X
>> {
>>    int a;
>>    int b = void; // also initialized to 0.
>> }
>>
>> This is because X must blit an init for a, and it would be silly to go  
>> through
>> the trouble of blitting X.init to a, but not b. Especially, for  
>> instance, if you
>> had an array of X (you'd have to blit every other int!)
>
> But it would not be silly for:
>
>    struct X {
>       int a;
>       int[100] b = void;
>    }
>
> to only initialize X.a. The compiler is allowed to optimize that. And,  
> in fact, I wished for just this in Warp.

I don't disagree. I think the spec should not specify what happens, to  
leave it open for future optimizations.

Has anyone ever considered making the compiler build an 'optimized'  
init-blitting function instead of just defaulting to memcpy? In other  
words, the compiler knows at compile time the layout and initialization  
values of a struct. What about using the compiler and optimizer to create  
the most optimized, no-runtime-variables function to blit memory? We  
wouldn't even need compiler help, if we did it with RTInfo.

-Steve


More information about the Digitalmars-d-announce mailing list