<div dir="ltr">-1 the #endif is much more clear and since it&#39;s so jarring you know its pre-compiler magic.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">







<p><b><font color="#cc0000">___________________________________</font></b></p><p><b>James⎥Head of Trolls</b></p><p><b><font color="#cc0000"><a href="mailto:james@supmenow.com" target="_blank">james@supmenow.com</a>⎥<a href="http://supmenow.com" target="_blank">supmenow.com</a></font></b></p><p><b><font size="2">Sup</font></b></p><p><b><font size="2">Runway East
</font></b></p><p><b><font size="2">10 Finsbury Square</font></b></p><p><b><font size="2">London</font></b></p><p><b><font size="2">
EC2A 1AF </font></b></p></div></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Fri, Mar 11, 2016 at 7:20 AM, David Hart via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>But in that case, you are placing #if at the same syntactic level as standard blocks and you loose a fair amount of expressive power.</div><div><div class="h5"><div><br>On 10 Mar 2016, at 20:03, Jean-Daniel Dupas &lt;<a href="mailto:mailing@xenonium.com" target="_blank">mailing@xenonium.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><br><div><blockquote type="cite"><div>Le 9 mars 2016 à 12:40, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br><div><div dir="auto"><div><span></span></div><div><div><span></span></div><div><div>You would at least need #} to disambiguate. With your proposal:</div><div><br></div><div>#if FALSE {</div><div>if false {</div><div>}</div><div>print(&quot;hello&quot;)</div><div>#if FALSE {</div><div>}</div><div>}</div><div><br></div><div>This either:</div><div>• is invalid syntax</div><div>• prints hello</div><div>• does nothing</div></div></div></div></div></blockquote><div><br></div>Swift required the block in compiler directive to be syntactically correct. So, you can’t have a dandling &quot;{&quot; and so that sample should not introduced ambiguity.</div><div><br><blockquote type="cite"><div><div dir="auto"><div><div><div><div>Sent from my iPhone</div>On 09 Mar 2016, at 02:22, Félix Cloutier via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>I don&#39;t think that this change can be implemented at all. `#if swift` doesn&#39;t parse inactive branches, so you wouldn&#39;t be able to disambiguate an `#if swift` end brace from a normal end brace.<br><div>
<br><span style="font-family:&#39;Lucida Grande&#39;;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Félix</span>
</div>

<br><div><blockquote type="cite"><div>Le 8 mars 2016 à 19:33:49, Richard Ross via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; a écrit :</div><br><div><span style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">-1. Keeping it the current way makes it significantly more obvious where the conditional compilation ends, rather than having to scour for yet another pesky curly brace.</span><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Additionally, some of us are logical and prefer not to use conditional compilation as an extra indentation level :)</span><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">--</span><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Richard</span><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote type="cite" style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Mar 8, 2016, at 4:23 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br>Swift inherited an odd preprocessor-related inconsistency from C, and I&#39;m wondering if we should change it.<br><br>Swift and C both use curly-bracket blocks to delimit if statements and other runtime control flow:<br><br><span style="white-space:pre-wrap">        </span>if foo {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>blah<br><span style="white-space:pre-wrap">        </span>}<br><span style="white-space:pre-wrap">        </span>else {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>yadda<br><span style="white-space:pre-wrap">        </span>}<br><br>However, the preprocessor/build configuration equivalent uses keywords in the style of languages like BASIC:<br><br><span style="white-space:pre-wrap">        </span>#if FOO<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>blah<br><span style="white-space:pre-wrap">        </span>#else<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>blah<br><span style="white-space:pre-wrap">        </span>#endif<br><br>In addition to the inconsistency, I consider this to have several concrete disadvantages:<br><br>- It leaves the preferred indentation of a conditional block ambiguous. Some people indent, others don&#39;t.<br>- It gives us no syntax to build on for other things that should be &quot;scoped&quot;. For instance, clang&#39;s `#pragma clang diagnostic push/pop` is as strange as it is because there&#39;s no sensible way to delimit a block structure.<br><br>C justifies this because the preprocessor is a separate pass with its own rules, but Swift does not have this limitation.<br><br>Therefore, I suggest we switch to this syntax:<br><br><span style="white-space:pre-wrap">        </span>#if FOO {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>blah<br><span style="white-space:pre-wrap">        </span>}<br><span style="white-space:pre-wrap">        </span>#else {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>blah<br><span style="white-space:pre-wrap">        </span>}<br><br>That gives us a basis to cleanly extend compiler directives to add new features. For instance, the #suppress directive discussed in the &quot;[Idea] #suppress(warning-identifier)&quot; could be given a syntax like this:<br><br><span style="white-space:pre-wrap">        </span>#suppress self-in-closure {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>blah<br><span style="white-space:pre-wrap">        </span>}<br><br>If their design ends up being purely compile-time with no runtime impact, we might even consider using this syntax for behaviors:<br><br><span style="white-space:pre-wrap">        </span>#behavior var lazy&lt;Value&gt;: Value {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>private var value: Value?<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>get {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>if let value = value {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>return value<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>}<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>let newValue = initialValue<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>value = newValue<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>return newValue<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>}<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>set {<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>value = newValue<br><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>}<br><span style="white-space:pre-wrap">        </span>}<br><br>There are two disadvantages I can identify:<br><br>- The fact that a particular } is associated with a compiler directive may not be immediately obvious when reading code.<br><br>- `#if swift(...)` may not be able to correctly parse the close of the block if unrecognized new language features inside the block appear to unbalance the curly brackets. (For instance, if a new literal syntax is used to quote a closing curly and older Swift compilers don&#39;t recognize it.)<br><br>If these problems are considered serious enough, an alternative would be to use `#}` to indicate the close of the compiler directive&#39;s scope. This is obviously not an ordinary curly bracket and is unlikely to appear in source for any other reason.<br><br>--<span> </span><br>Brent Royal-Gordon<br>Architechies<br><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.swift.org_mailman_listinfo_swift-2Devolution&amp;d=CwIGaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=Ezje1IF3xGXfUMfsj4fBc7oM7BcJys1dhQ6psfXzLMU&amp;m=KpVD5NRN240WmQvnHJitBkkgyBtlHU87STAlrcfVNSA&amp;s=V6Bvu749V2ofSYff-m5YKMX_g5Yr48jKkjCeBANWe4w&amp;e=" target="_blank">https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.swift.org_mailman_listinfo_swift-2Devolution&amp;d=CwIGaQ&amp;c=5VD0RTtNlTh3ycd41b3MUw&amp;r=Ezje1IF3xGXfUMfsj4fBc7oM7BcJys1dhQ6psfXzLMU&amp;m=KpVD5NRN240WmQvnHJitBkkgyBtlHU87STAlrcfVNSA&amp;s=V6Bvu749V2ofSYff-m5YKMX_g5Yr48jKkjCeBANWe4w&amp;e=</a><span> </span><br></blockquote><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">_______________________________________________</span><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Menlo-Regular;font-size:10px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></div>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></blockquote></div></div></div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>