<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 7 December 2017 at 17:20, Manu <span dir="ltr"><<a href="mailto:turkeyman@gmail.com" target="_blank">turkeyman@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div class="gmail-h5"><div class="gmail_extra"><div class="gmail_quote">On 7 December 2017 at 13:35, Walter Bright via Digitalmars-d <span dir="ltr"><<a href="mailto:digitalmars-d@puremagic.com" target="_blank">digitalmars-d@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On 12/7/2017 11:41 AM, Manu wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Misuse of the API; ie, a runtime call, will result in an unsuspecting user getting a surprising link error, rather than a nice compile-time error explaining what they did wrong...<br>
</blockquote>
<br></span>
I think Nicholas is talking about functions for which code cannot be generated.<br>
<br>
In any case, in C/C++/D if you call functions in .h files (or imports) that are not linked in, you'll get a linker error.<br>
</blockquote></div><br></div></div></div><div class="gmail_extra">Right, but that's what I'm saying; using your solution of putting a function in a module that's not compiled to inhibit code generation won't inhibit people from *attempting* to making runtime calls (and getting link errors)... whereas a compile error trying to runtime-call a function that shouldn't be runtime-called might be more desirable.</div><div class="gmail_extra">I'm not actually registering support for @ctfeonly, just that I think it's a pattern that I have wanted and should be supported in some way, and a compile-time error would be nicer than a link error.</div></div>
</blockquote></div><br></div><div class="gmail_extra">I tried this, and was surprised it didn't work:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">int ctfeOnly(int x)</div><div class="gmail_extra">{</div><div class="gmail_extra"><span style="white-space:pre">      </span>static assert(__ctfe);</div><div class="gmail_extra"><span style="white-space:pre">  </span>return x + 1;<br></div><div class="gmail_extra">}</div><div><br></div><div>This would probably solve the problem in a satisfying way without an attribute?</div></div></div>