<div class="gmail_quote">On 4 January 2012 16:28, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On 1/4/12 3:39 AM, Manu wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
  * __forceinline ... I wasn't aware this didn't exist... and yes,<br>
despite all this discussion, I still depend on this all the time. People<br>
are talking about implementing forceinline by immitating macros using<br></div>
mixins.... crazy? Here's a solid reason I avoid mixins or procedurally<div class="im"><br>
generated code (and the preprocessor in C for that matter, in favour of<br>
__forceinline): YOU CAN DEBUG IT. In an inline function, the code exists<br>
in the source file, just like any other function, you can STEP THE<br>
DEBUGGER through it, and inspect the values easily. This is an<br>
underrated requirement. I would waste hours on many days if I couldn't<br>
do this. I would only ever use string mixins for the most obscure uses,<br>
preferring inline functions for the sake of debugging 99% of the time.<br>
</div></blockquote>
<br>
Hmmm, I see that the other way around. D CTFE-generated macros are much easier to debug because you can actually print the code before mixing it in. If it looks like valid code... great.<br>
<br>
I think the deal with inline functions is significantly more complex. Inlining is the first step in a long pipeline of optimizations that often make the code virtually unrecognizable and impossible to map back to source in a way that's remotely understandable.</blockquote>
<div><br></div><div>It's rare to step through optimised code. You tend to debug and step in debug/unoptimised builds, where inline functions are usually not even inlined, and code flow still looks natural, and easy to follow.. This saves lots of time.</div>
<div>C/C++ macros present the same problem of not being able to step and inspect values. Most industry programmers I work with tend to avoid macros for this reason above all others.</div></div>