<div dir="ltr"><div class="markdown-here-wrapper" style=""><p style="margin:0px 0px 1.2em!important">I think this would be an anti-feature , here are some reasons why:</p>
<ul style="margin:1.2em 0px;padding-left:2em">
<li style="margin:0.5em 0px">If it is code you wrote as an idea for how something might be  implemented in the future, then it should be manually tweaked/validated anyway when you  put it back in. If things change slightly such that your old commented code breaks when  you comment it back in this is a good thing, it forces you to  check/amend the old code so that it functions properly in the updated  environment that it now inhabits.</li>
<li style="margin:0.5em 0px">If it’s a significant amount of code then it really ought to be  structured into something appropriate, like a function or a class, in which case it can happily live uncalled and not commented out. But it’s not a great practice to leave unused code lying around, unless you know it’s going to be used soon.</li>
<li style="margin:0.5em 0px">Commented code is often commented out specifically to make things compile while you tweak/break things somewhere else (i.e. commented out temporarily) - so of course you don’t want it to be compiled.</li>
<li style="margin:0.5em 0px">If you comment out code temporarily then it really should just mean temporarily, i.e. between now and your next commit to test something immediately. Source control means there’s no need for longer-lived commented out code. Unfinished code can live on a branch, old code that you might want to refer to or re-use later is in your source control history, and unused code should probably just be removed.</li>
<li style="margin:0.5em 0px">Code that is written and working and intended to be enabled later on should be activated by a feature-toggle (either a compile-time or a run-time one) rather than commented out.</li>
</ul>
<div title="MDH:PGRpdj5JIHRoaW5rIHRoaXMgd291bGQgYmUgYW4gYW50aS1mZWF0dXJlICwgaGVyZSBhcmUgc29t
ZSByZWFzb25zIHdoeTo8YnI+KiBJZiBpdCBpcyBjb2RlIHlvdSB3cm90ZSBhcyBhbiBpZGVhIGZv
ciBob3cgc29tZXRoaW5nIG1pZ2h0IGJlIAppbXBsZW1lbnRlZCBpbiB0aGUgZnV0dXJlLCB0aGVu
IGl0IHNob3VsZCBiZSBtYW51YWxseSB0d2Vha2VkL3ZhbGlkYXRlZCBhbnl3YXkgd2hlbiB5b3Ug
CnB1dCBpdCBiYWNrIGluLiBJZiB0aGluZ3MgY2hhbmdlIHNsaWdodGx5IHN1Y2ggdGhhdCB5b3Vy
IG9sZCBjb21tZW50ZWQgY29kZSBicm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ZWVuIG5vdyBhbmQgeW91ciBuZXh0IGNvbW1pdCB0byB0ZXN0IHNvbWV0
aGluZyBpbW1lZGlhdGVseS4gU291cmNlIGNvbnRyb2wgbWVhbnMgdGhlcmUncyBubyBuZWVkIGZv
ciBsb25nZXItbGl2ZWQgY29tbWVudGVkIG91dCBjb2RlLiBVbmZpbmlzaGVkIGNvZGUgY2FuIGxp
dmUgb24gYSBicmFuY2gsIG9sZCBjb2RlIHRoYXQgeW91IG1pZ2h0IHdhbnQgdG8gcmVmZXIgdG8g
b3IgcmUtdXNlIGxhdGVyIGlzIGluIHlvdXIgc291cmNlIGNvbnRyb2wgaGlzdG9yeSwgYW5kIHVu
dXNlZCBjb2RlIHNob3VsZCBwcm9iYWJseSBqdXN0IGJlIHJlbW92ZWQuPGJyPjwvZGl2PjxkaXY+
KiBDb2RlIHRoYXQgaXMgd3JpdHRlbiBhbmQgd29ya2luZyBhbmQgaW50ZW5kZWQgdG8gYmUgZW5h
YmxlZCBsYXRlciBvbiBzaG91bGQgYmUgYWN0aXZhdGVkIGJ5IGEgZmVhdHVyZS10b2dnbGUgKGVp
dGhlciBhIGNvbXBpbGUtdGltZSBvciBhIHJ1bi10aW1lIG9uZSkgcmF0aGVyIHRoYW4gY29tbWVu
dGVkIG91dC48YnI+PGJyPjwvZGl2Pg==" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0">​</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, 15 Jan 2017 at 00:04 Amir Michail via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 14, 2017, at 6:56 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_7746844309069193950Apple-interchange-newline gmail_msg"><div class="gmail_msg"><br class="m_7746844309069193950Apple-interchange-newline gmail_msg"><br style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><div class="gmail_quote gmail_msg" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">On Sat, Jan 14, 2017 at 5:50 PM, Amir Michail<span class="m_7746844309069193950Apple-converted-space gmail_msg"> </span><span dir="ltr" class="gmail_msg">&lt;<a href="mailto:a.michail@me.com" class="gmail_msg" target="_blank">a.michail@me.com</a>&gt;</span><span class="m_7746844309069193950Apple-converted-space gmail_msg"> </span>wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><span class="m_7746844309069193950gmail- gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 14, 2017, at 6:46 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class="m_7746844309069193950gmail-m_5581296995374281999Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg">On Sat, Jan 14, 2017 at 5:35 PM, Amir Michail<span class="m_7746844309069193950Apple-converted-space gmail_msg"> </span><span dir="ltr" class="gmail_msg">&lt;<a href="mailto:a.michail@me.com" class="gmail_msg" target="_blank">a.michail@me.com</a>&gt;</span><span class="m_7746844309069193950Apple-converted-space gmail_msg"> </span>wrote:<br class="gmail_msg"><div class="gmail_extra gmail_msg"><div class="gmail_quote gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><span class="gmail_msg"><br class="gmail_msg">&gt; On Jan 14, 2017, at 6:28 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="gmail_msg" target="_blank">xiaodi.wu@gmail.com</a>&gt; wrote:<br class="gmail_msg">&gt;<br class="gmail_msg">&gt; This has been brought up on this list before. The conclusion of the previous thread on this topic was that there is a way to do this:<br class="gmail_msg">&gt;<br class="gmail_msg">&gt; #if false<br class="gmail_msg">&gt; // put your code here<br class="gmail_msg">&gt; #endif<br class="gmail_msg">&gt;<br class="gmail_msg"><br class="gmail_msg"></span>This would not check the code for compilability within the surrounding code. This requires more than a syntax check.</blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I can&#39;t say I&#39;ve ever needed that feature; could you share a concrete use case?</div><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></span><div class="gmail_msg">Consider an array of levels for a game where some levels are commented out for possible future use. It would be nice to have such level entries continue to compile as the code elsewhere evolves and yet not be included in the executable.</div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div><div class="gmail_msg"><div class="gmail_msg">enum Levels: Int {</div><div class="gmail_msg">  case foo = 1, bar, baz, boo</div><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div></div><div class="gmail_msg"><div class="gmail_msg">var levels: [Levels] = [</div><div class="gmail_msg">  .foo,</div><div class="gmail_msg">  .bar,</div><div class="gmail_msg">]</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">// disabled</div><div class="gmail_msg">_ = {</div><div class="gmail_msg">  levels += [</div><div class="gmail_msg">    .baz,</div><div class="gmail_msg">    .boo,</div><div class="gmail_msg">    // this won&#39;t compile if you add:</div><div class="gmail_msg">    // .nonExistent,</div><div class="gmail_msg">  ]</div><div class="gmail_msg">}</div></div><div class="gmail_msg">```</div></div></div></blockquote></div><br class="gmail_msg"></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">That’s helpful thanks! I still think code comments would be nice though.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>