<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 29, 2016 at 4:15 PM, DifferentApps info via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for your pattern suggestion.<br>
But it would be also possible to switch between implementations with the proposed syntax as shown bellow:<br>
<br>
/{<br>
<code 1><br>
}/<br>
do {<br>
<code 2><br>
<div class="HOEnZb"><div class="h5">}<br>
<br></div></div></blockquote><div><br></div><div>That would be greatly inferior, as you'd have to edit the code in four distinct places, versus a single one (change #if false to #if true).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
<br>
Le 29 août 2016 à 22:53, Magnus Ahltorp <<a href="mailto:map@kth.se">map@kth.se</a>> a écrit :<br>
<br>
>> 29 Aug. 2016 22:16 DifferentApps info <<a href="mailto:andre_ponzo@differentapps.com">andre_ponzo@differentapps.com</a><wbr>> wrote:<br>
>><br>
>> The advantage is that you do not need to define a conditional flag for the #if.<br>
><br>
> The good news is, you don't.<br>
><br>
> #if false<br>
> print("Disabled code")<br>
> #endif<br>
><br>
> which is a time-tested way of writing C code (using #if 0).<br>
><br>
> From the Swift changelog, where they even call it an idiom of C:<br>
><br>
> 2014-04-30<br>
> […]<br>
> * You can now use the `true` and `false` constants in build configurations,<br>
> allowing you to emulate the C idioms of `#if 0` (but spelled `#if false`).<br>
><br>
> One pattern I use all the time, both in C and in Swift, is this:<br>
><br>
> #if false<br>
> <experimental code><br>
> #else<br>
> <old code><br>
> #endif<br>
><br>
> which makes it possible to switch between the implementations quickly, something you cannot do with the proposed syntax.<br>
><br>
>> Code disabling (with /{...}/) is a tool useful when developing algorithm, and disabled code should not be aimed to remain definitively in a Swift file.<br>
><br>
> Which is in no way dependent on if you use the proposed syntax, traditional comments, or conditional compilation.<br>
><br>
> /Magnus<br>
><br>
<br>
______________________________<wbr>_________________<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/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</div></div></blockquote></div><br></div></div>