<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 1, 2016 at 9:09 PM, David Nadlinger via Digitalmars-d-announce <span dir="ltr"><<a href="mailto:digitalmars-d-announce@puremagic.com" target="_blank">digitalmars-d-announce@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Thursday, 1 September 2016 at 16:43:53 UTC, Rory McGuire wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
is that in one of the "semantic" passes the compiler has?<br>
</blockquote>
<br></span>
For reference, I've laid out the reasons why this proposal couldn't work to Stefan here: <a href="https://github.com/dlang/dmd/pull/6098#issuecomment-243375543" rel="noreferrer" target="_blank">https://github.com/dlang/dmd/p<wbr>ull/6098#issuecomment-24337554<wbr>3</a><br>
<br>
The real reason is not so much in the pass structure of the compiler as in the fact that CTFE by definition executes the same function body that is also emitted to the runtime binary.<br>
<br>
 — David<br>
</blockquote></div><br></div><div class="gmail_extra">okay thanks, I'll take a look at the link.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Question: if the function runs the same, why can't I catch the exception? From what Stefan said even if I could catch the exception static if still wouldn't compile different code.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">bool _checkCTFE() {</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>try {</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>import std.uuid;</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">         </span>enum id = new UUID("8AB3060E-2cba-4f23-b74c-b52db3bdfb46");</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>return false;</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>} catch (Throwable t) {</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">          </span>return true;</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>}</div><div class="gmail_extra">}</div><div><br></div><div>The above still fails during CTFE, compiler just exists with:</div><div><div>enforceCTFE.d(20): Error: variable enforceCTFE._checkCTFE.id : Unable to initialize enum with class or pointer to struct. Use static const variable instead.</div></div><div><br></div><div><br></div><div>So why can't we even catch the Error during CTFE, that would at least help somewhat.</div><div><br></div><div>At the moment I just have a verbose logging mode with pragma(msg) for my CTFE stuff.</div><div><br></div></div><div class="gmail_extra"><br></div></div>