<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><div><span></span></div><div><div>Some thoughts, inline<br><br>~Robert Widmann</div><div><br>2017/01/14 18:18、Amir Michail via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; のメッセージ:<br><br></div><blockquote type="cite"><div><span>The code in a “code comment" must compile (not just be syntactically correct) yet must not have any effect on the resulting executable.</span><br></div></blockquote><div><br></div><div>What is the definition of "compile"? &nbsp;It truly matters because certain definitions you give will have serious security threats associated with them. &nbsp;</div><div><br></div><div>There's also a certain style of linter tool that is built for running code in documentation to check its correctness (Scala has a famous one in the form of Tut (<a href="https://github.com/tpolecat/tut">https://github.com/tpolecat/tut</a>). &nbsp;Tut spins up individual REPL sessions per comment so is built to be run as a commit hook or as part of CI builds, not something live (a bit like a miniature playground) running inside the IDE. &nbsp;On the other hand, for the majority of code comments it probably suffices to just get it through typechecking. &nbsp;You won't have the benefit of checking its execution, but at least you'll know you have some well-formed code in the comment.</div><br><blockquote type="cite"><div><span></span><br><span>For example, commented entries in an array would be checked for compilability but would not be included in the executable.</span><br></div></blockquote><div><br></div>We suddenly have to demarcate which parts of the language are "safe" versus "unsafe" is what you mean? &nbsp;This sounds incredibly brittle and borderline unenforceable.</div><div><br><blockquote type="cite"><div><span></span><br><span>Such “code comments" would allow you to have code/data that is currently unused but is constantly checked to be valid just in case you want to use it in the future.</span><br></div></blockquote><div><br></div><div>There is a way to go about doing this in a safe and productive manner, but it may not quite be the way you see it in your minds' eye. &nbsp;If you want code execution you have to trade in security. &nbsp;If you want live/quick results you have to give up execution. &nbsp;Lord knows we don't need malicious comments to be the source of the next Xcode Ghost nor do we need to slow the IDE to a crawl checking a thousand comment sheds in a thousand REPL sessions.</div><br><blockquote type="cite"><div><span></span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></body></html>