<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span class="tab"> Sorry, did not mean this to be private...<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">----- Forwarded Message -----<br><b><span style="font-weight:bold;">From:</span></b> Steve Schveighoffer <schveiguy@yahoo.com><br><b><span style="font-weight: bold;">To:</span></b> Don Clugston <dclugston@googlemail.com><br><b><span style="font-weight: bold;">Sent:</span></b> Friday, September 16, 2011 8:57 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [dmd-internals] Fixing forward ref bugs for good<br></font><br><meta
 http-equiv="x-dns-prefetch-control" content="off"><div id="yiv398287630"><div style="color:#000;background-color:#fff;font-family:arial, helvetica, sans-serif;font-size:12pt;"><div><span>What I mean is, it feels like the wrong approach to ordering.  I'd rather ordering be dependent on ordering, not nesting.  It seems like a counter-intuitive way to do ordering that has the same issues using the order of declaration.<br></span></div><div><br><span></span></div><div><span>People are going to look at some file that has static if(true) (or several levels of them!) and scratch their heads, potentially removing it.</span></div><div><br><span></span></div><div><span>Are we trying to say here, ordering matters only for static ifs?  Then why can't the ordering just be the order they appear?  Is there any advantage to use nesting?  What about some sort of pragma or @annotation to define ordering?</span></div><div><br></div><div>And what
 about repeatedly trying evaluating a static if until it can be
 evaluated, or you are stuck?  Has that been considered and rejected for some reason?</div><div><br><span></span></div><div><span>Again, not understanding all the issues, so maybe it's just the only way possible.  But it sure looks bad.<br></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> Steve Schveighoffer <schveiguy@yahoo.com>; Discuss the internals of DMD <dmd-internals@puremagic.com><br><b><span style="font-weight:bold;">Sent:</span></b> Friday,
 September 16, 2011 8:37 AM<br><b><span style="font-weight:bold;">Subject:</span></b> Re: [dmd-internals] Fixing forward ref bugs for good<br></font><br>On 16 September 2011 13:25, Steve Schveighoffer <<a rel="nofollow" ymailto="mailto:schveiguy@yahoo.com" target="_blank" href="mailto:schveiguy@yahoo.com">schveiguy@yahoo.com</a>> wrote:<br>> Not really understanding all the issues here, but this looks horrible :(<br>> I hope this isn't the solution.<br>> -Steve<br><br>Are you reacting to the concept, or only to the syntax?<br>Bear in mind that it occurs ONLY when you have dependent static ifs<br>within a single scope.<br>For example, if you have a 'static if' inside a template, struct, or<br>function, it has access to ALL symbols in that module.<br>In my opinion, this normally (not always, but normally) indicates a<br>poor design. It can almost always be factored out (eg, by creating a<br>bool enum).  Worst case, we could add some
 syntax sugar.<br>I think that if
 you really want to have semantics which are<br>independent of the ordering of declarations, then by definition you<br>can't have dependent static ifs in the same scope.<br>The second option is to allow ordering to be significant only for<br>mixins and static if. And in that case, the ordering has to be strict:<br>even if something near the end of the file is 'static if(1)', the<br>declarations in it are not available anywhere else in the scope.<br>I think any other option (like evaluating every static if that doesn't<br>use is(typeof()) or other forms of reflection, before those that do)<br>leads to madness.<br><br><br>> From: Don Clugston <<a rel="nofollow" ymailto="mailto:dclugston@googlemail.com" target="_blank" href="mailto:dclugston@googlemail.com">dclugston@googlemail.com</a>><br>> On 15 September 2011 17:56, Andrei Alexandrescu <<a rel="nofollow" ymailto="mailto:andrei@erdani.com" target="_blank"
 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 rel="nofollow" ymailto="mailto:mrmocool@gmx.de" target="_blank" href="mailto:mrmocool@gmx.de">mrmocool@gmx.de</a>>  wrote:<br>>>>><br>>>>> Am 15.09.2011, 11:44 Uhr, schrieb Don<br>>>>> Clugston<<a rel="nofollow" ymailto="mailto:dclugston@googlemail.com" target="_blank" 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<br>>> 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<br>>> 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 rel="nofollow" ymailto="mailto:dmd-internals@puremagic.com" target="_blank" href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>> <a rel="nofollow" target="_blank" href="http://lists.puremagic.com/mailman/listinfo/dmd-internals">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br>><br>><br>><br>> _______________________________________________<br>> dmd-internals mailing list<br>> <a rel="nofollow" ymailto="mailto:dmd-internals@puremagic.com" target="_blank" href="mailto:dmd-internals@puremagic.com">dmd-internals@puremagic.com</a><br>> <a rel="nofollow" target="_blank"
 href="http://lists.puremagic.com/mailman/listinfo/dmd-internals">http://lists.puremagic.com/mailman/listinfo/dmd-internals</a><br>><br><br><br></div></div></blockquote></div></div></div><meta http-equiv="x-dns-prefetch-control" content="on"><br><br></div></div></blockquote></div></div></body></html>