<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 19, 2016, at 4:50 AM, David Goodine via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey all,<div class=""><br class=""></div><div class="">I don’t know if this is really an ‘evolution’ topic per se, and I’m not on Swift Dev, but thought someone here could shed some light on this.</div><div class=""><br class=""></div><div class="">Often when developing code, if I need create mode switches (constant Bools) so that I can move back and forth between different features/implementations for testing, developing experimental features, migration, etc. Currently if I write the following:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">let useFoo = true</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">if useFoo {</font></div><div class=""><font face="Courier" class="">// Foo code</font></div><div class=""><font face="Courier" class="">} else {</font></div><div class=""><font face="Courier" class="">// Non-Foo code</font></div><div class=""><font face="Courier" class="">}</font></div></div></div></blockquote><br class=""></div><div>In your debugging, do you actually need this condition to be evaluated at runtime? For example, in the debugger, are you changing the value of useFoo at runtime to switch which branch is used?</div><div><br class=""></div><div>If not, maybe #if would be better — it makes the decision at compile time. I don't get any warnings from the following code:</div><div><br class=""></div><div class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Courier" class="">let useFoo = true</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">#if useFoo</font></div><div class=""><font face="Courier" class=""> print("foo code")</font></div><div class=""><font face="Courier" class="">#else</font></div><div class=""><font face="Courier" class=""> print("non-foo code")</font></div><div class=""><font face="Courier" class="">#endif</font></div></blockquote><div class=""><br class=""></div></body></html>