SDC & ddmd

Timon Gehr timon.gehr at gmx.ch
Sat Dec 10 03:17:17 PST 2011


On 12/10/2011 10:54 AM, Bernard Helyer wrote:
> On Saturday, 10 December 2011 at 09:47:14 UTC, Timon Gehr wrote:
>> On 12/10/2011 10:40 AM, Bernard Helyer wrote:
>>> We intend to be compatible with DMD to a point. Where we are not, will
>>> be through omission. Off the top of my head:
>>> [...]
>>> *D's forward reference and module order bugs will not be supported.
>>>
>>> [snip.]
>>>
>>
>> How is that an 'omission'?
>
> Just my lame attempt at humour. :P

Should have thought of that. =)
Do you already have a working design? I think what Don suggested 
(process static if and mixins in sequence, everything else on by need 
basis) does not work in the general case because you can have static if 
and mixin declaration dependencies across module import cycles.

I think the way it should work would be similar to this sketch:

Evaluate all static if's and mixin declarations until a symbol not 
defined in the current scope is hit. Repeat. As soon as all remaining 
mixins and static ifs have been blocked like that, consider the 
enclosing scope and decide that the symbol does not exist in the current 
scope. Repeat the whole process until a fixed point is reached. At that 
point decide that all remaining unresolved symbols do not exist. Repeat 
until everything is evaluated. If at any point a symbol is defined that 
has been decided not to exist in another mixin or static if declaration, 
emit an 'illegally dependent on static evaluation order' error.

It is not exactly trivial to get right, but if I am not mistaken, the 
result should be powerful, intuitive and evaluation order independent. 
It even allows patterns like static if(!is(typeof(foo)) enum foo = 
bar();, while banning static if(!is(typeof(bar)) enum foo = 1; static 
if(!is(typeof(foo)) enum bar = 1;


More information about the Digitalmars-d mailing list