Non compile time evaluation for initializers

Lutger lutger.blijdestijn at gmail.com
Fri Oct 26 01:50:40 PDT 2007


Janice Caron wrote:
> On 10/25/07, Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>> Is there a good reason why the compiler does not allow non-CTFE initializers
>> for non-const variables?
> 
> So you're saying that, in general, if
> 
>     X x = y;
> 
> won't compile, then the compiler should rewrite it as
> 
>     X x;
>     static this
>     {
>         x = y;
>     }
> 
> Makes sense to me!

Suppose this is implemented, then how can you achieve constant folding 
with CTFE in initializers? Since it is not a compile time context 
anymore, all functions that substitue y will be evaluated at runtime.



More information about the Digitalmars-d mailing list