dmd 1.047 and 2.032 releases

Don nospam at nospam.com
Fri Sep 4 06:55:36 PDT 2009


bearophile wrote:
> Don:
> 
>> CTFE is almost completely isolated from the rest of the compiler: it can't break anything that's  not CTFE.<
> 
> It's like having a compiler plus a D1 interpreter. In theory this duplication looks silly, in practice it seems handy.

Interestingly, by *requiring* the compiler to provide an interpreter, 
the language can make optimisation guarantees about constant folding, 
_independent of the backend_.

>> It is likely, for example, that unions will need to be disallowed in CTFE,<
> 
> Can you tell me why?

Suppose you have:

align(2):
struct S
{
   char d;
   int a;
   char [2] b;
}

union U {
   byte[5] a;
   double x;
   S c;
}

and you write to u.c.d, and u.a[3] what value is x? It's disgusting. 
Depends on the endianness of the target system, for example.

>> but there's absolutely no reason why 'new' expressions should be disallowed.<
I mean things like:
int [] a = new int[n];
which is trivial -- about 5 lines of code.

Oh. And the D1 spec doesn't disallow inline asm in CTFE.
But CTFE asm is Not Going To Happen. <g>


More information about the Digitalmars-d-announce mailing list