<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>Not really understanding all the issues here, but this looks horrible :(</span></div><div><br><span></span></div><div><span>I hope this isn't the solution.</span></div><div><br><span></span></div><div><span>-Steve<br></span></div><div><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"><font face="Arial" size="2"><hr size="1"><b><span style="font-weight:bold;">From:</span></b> Don Clugston <dclugston@googlemail.com><br><b><span style="font-weight: bold;">To:</span></b> Discuss the internals of DMD <dmd-internals@puremagic.com><br><b><span style="font-weight: bold;">Sent:</span></b> Friday, September 16, 2011 2:04
 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [dmd-internals] Fixing forward ref bugs for good<br></font><br>On 15 September 2011 17:56, Andrei Alexandrescu <<a ymailto="mailto:andrei@erdani.com" href="mailto:andrei@erdani.com">andrei@erdani.com</a>> wrote:<br>> On 9/15/11 6:53 AM, Don Clugston wrote:<br>>><br>>> On 15 September 2011 13:14,<<a ymailto="mailto:mrmocool@gmx.de" href="mailto:mrmocool@gmx.de">mrmocool@gmx.de</a>>  wrote:<br>>>><br>>>> Am 15.09.2011, 11:44 Uhr, schrieb Don Clugston<<a ymailto="mailto:dclugston@googlemail.com" href="mailto:dclugston@googlemail.com">dclugston@googlemail.com</a>>:<br>>>>><br>>>>> I think there is a simple solution to 'static if'.<br>>>>> Do const folding on every static if condition, giving a boolean result.<br>>>>> Do NOT evaluate any static if bodies yet.<br>>>>> This would
 have the same effect as if every 'static if' were evaluated<br>>>>> simultaneously.<br>>>><br>>>> What if the condition includes symbols from another static if's body or<br>>>> mixin or whatever?<br>>><br>>> I think that should be disallowed.<br>><br>> I see an issue here with cross-module use. For example, it's nice to have:<br>><br>> import some.module;<br>><br>> static if (is(typeof(some.module.foobar) == int)) {<br>>   alias some.module.foobar baz;<br>> } else {<br>>   enum baz = 42; // or whatever<br>> }<br>><br>> So far so good. The problem now is that some.module uses a similar technique<br>> to introduce that symbol foobar, the code won't work anymore.<br>><br>> I also realized that code relying on enumerating symbols in a module (like<br>> benchmark does) or a class (like an introspection library does) will miss<br>> all symbols
 guarded by static if. And, for example, ranges define plenty of<br>> those. This erodes the power of static if substantially.<br><br>Not so. The thing is, static ifs can be nested. Only one level of<br>static if is removed at a time.<br>If you simply wrap the static if inside static if(true) {...}<br>it won't be evaluated until all the first-level static ifs have added<br>their symbols to the scope.<br><br>So the current:<br>static if (cond1)<br>{<br>    A;<br>}<br>static if (cond2)<br>{<br>   B;<br>}<br>where cond2 depends on A, can be rewritten in the 'parallel execution'<br>paradigm as:<br>static if (cond1)<br>{<br>    A;<br>}<br>static if (true)<br>{<br>  static if (cond2)<br>  {<br>     B;<br>  }<br>}<br>Order of execution is controlled by depth of nesting, instead of by<br>order in the file.<br>Note that in your first example, the question of which module<br>instantiates the symbol is determined
 not even by order within the<br>file, but by which module is first on the command line -- ie, it's<br>determined by the makefile!<br>_______________________________________________<br>dmd-internals mailing list<br><a ymailto="mailto:dmd-internals@puremagic.com" href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br><a href="http://lists.puremagic.com/mailman/listinfo/dmd-internals" target="_blank">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br><br><br></div></div></blockquote></div></div></body></html>