<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div><br>On Apr 20, 2014, at 3:09 PM, Mark Rowe &lt;<a href="mailto:mrowe@apple.com">mrowe@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><br><div><div>On Apr 20, 2014, at 14:50, Filip Pizlo &lt;<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Apr 20, 2014, at 2:43 PM, Mark Rowe &lt;<a href="mailto:mrowe@apple.com">mrowe@apple.com</a>&gt; wrote:<br><br><br><blockquote type="cite">On Apr 20, 2014, at 14:02, Filip Pizlo &lt;<a href="mailto:fpizlo@apple.com">fpizlo@apple.com</a>&gt; wrote:<br><br>The #if means that the code being guarded isn't indented. I believe that indenting control flow is a good idea.<span class="Apple-converted-space">&nbsp;</span><br><br>Also, using normal if's whenever it would compile and be semantically equivalent means that the code being protected would benefit from syntax/type/semantic checking even in a release build.<br></blockquote><br>We use preprocessor defines to distinguish between many things besides debug and release builds, and in many cases it’s impossible to tell ahead of time whether the alternate paths will compile on all platforms. This is particularly true for code guarded by defines related to the compiler, target platform, or OS version, but is also a concern with feature defines where symbols have been #if’d out.<br><br><blockquote type="cite">I think of this as being analogous to our preference for static assertions: we use them whenever we can but resort to dynamic assertions when we can't.<br></blockquote><br>I don’t think this is a great analogy. It’s usually clear from the context whether what you’re asserting is a compile-time or run-time concept, and thus whether a compile-time or run-time assertion is appropriate. It’s far from obvious whether all branches of an if will compile.<br></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">In the cases that I'm concerned with, I don't care if the code guarded by ASSERT_DISABLED will compile, only whether it will run. This is mostly, but not entirely, different from CPU guards - even those may be dynamic like in the case of tests for exotic SSE capabilities.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"></blockquote><div><br></div>I’m not sure what you’re trying to say here. Surely you care that the code compiles without warnings, since otherwise you’d break the build.</div></div></blockquote><div><br></div><div>I may have misunderstood your point and gone off on a tangent, so this may no longer be related to my proposal. What I mean by "the code will compile" is whether the compiler will see the code after preprocessing completes. That's the key distinction between #if and if - #if prevents code from being compiled.&nbsp;</div><br><blockquote type="cite"><div><div> Can you elaborate on the difference you see between ASSERT_DISABLED checks and platform-related checks (OS, OS version, CPU architecture, etc), and what impact that difference has on your proposal?</div></div></blockquote><div><br></div><div>I don't think it impacts my proposal at all - if it was possible to case on CPU without using #if and it would result in the same run-time behavior we would have gotten from the #if, then I would prefer to do it would the preprocessor to keep the code cleaner.&nbsp;</div><br><blockquote type="cite"><div><div><br><blockquote type="cite"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">I don't think you can make a hard and fast rule based on the compile versus run distinction. You can make one based on semantic equivalence (if it's equivalent then avoid the preprocessor). So, I think that if the only goal here was to make an enforceable rule then my proposal is somewhat better.<span class="Apple-converted-space">&nbsp;</span></span></blockquote><br></div><div>I’m not sure exactly what you mean by semantic equivalence here. #if vs if inherently have different semantics.</div></div></blockquote><div><br></div><div>I mean that if in a particular case, using #if and if would result in identical behavior, then if should be used. Obviously this doesn't apply to all cases because it is predicated on there being identical behavior and of course the behavior won't always be identical.&nbsp;</div><br><blockquote type="cite"><div><div><br></div><div>- Mark</div><div><br></div></div></blockquote></body></html>