<div dir="ltr">I'm used to the name "directive" from C preprocessor nomenclature, but I think it would best be used for all of #available, #selector, and #line, in addition to #if/#else/#endif.<div><br></div><div>Maybe "#if" is a "conditional directive", and "os(...) && swift(...)" is simply its condition.<br><div><br></div><div>-D "Defines" something (a flag). Perhaps it "defines a flag such that the '#if flag' condition is true".</div><div class="gmail_extra">
<br><div class="gmail_quote">On Wed, Jan 27, 2016 at 5:18 PM, Jordan Rose 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word">Hi, everyone. This isn't <i>exactly</i> a language feature, but it's something that would benefit from the idea pool and bikeshedding that happens on the list. Simply put, what's the name of this feature?<div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>#if os(OSX)</div><div>#if swift(>=3.0)</div><div>#if DEBUG</div></blockquote><br><div>And what's this command-line option? (not that most people are invoking Swift on the command line)</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>swift -DDEBUG main.swift</div></blockquote><br><div>---</div><div><br></div><div>The <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/compiler-control-statement" target="_blank">Swift Programming Language book</a> and the compiler diagnostics aren't quite consistent here:</div><div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div>#if: "configuration block" (compiler), "build configuration statement" (book)</div><div>(the condition): "build configuration expression" (compiler), "build configuration" (book)</div><div>os(…) and arch(…): "target configuration expression" (compiler), "platform testing function" (book)</div><div>swift(>=…): "version requirement" (compiler), (not yet in book)</div><div><br></div><div>-D flag: "specifies one or more build configuration options"</div></blockquote><div><br></div><div>On top of this, there's another problem: the term "build configuration" has long been used by Xcode to refer to "Debug", "Release", etc—a different mode of compilation that manifests itself as different build settings. Having two different concepts with the same name is never a great idea, and Xcode's feature definitely has seniority here.</div><div><br></div><div>---</div><div><br></div><div>Some things to keep in mind for this feature:</div><div><br></div><div>- All conditions are (currently) compile-time conditions.</div><div>- Code in the non-compiled block still has to parse…except if the predicate is "swift(>=…)", for obvious reasons.</div><div>- All conditions are boolean-valued predicates; the ones set on the command line are options (present or absent), not macros.</div><div><br></div><div>Here's my proposed names to get the discussion started:</div><div><br></div><div>- "Conditional Compilation Block" for the whole construct (from the #if to the #endif and everything in between).</div><div>- "Conditional Compilation Directive" for the #if line (and #elseif line). Not sure if the #endif line applies.</div><div>- "Conditional Compilation Expression" for the condition of a #if.</div><div>- "Platform Compilation Features" for all the function-like predicates (including "swift(>=…)", even though that's special.</div><div>- "Custom Compilation Features" for all the user-defined options.</div><div>- "marks a custom compilation feature as present" as the --help text for -D.</div><div><br></div><div>…but I'd be happy if someone comes up with something better. (And I'd like feedback on if any of these names are problematic in some other way.)</div><div><br></div><div>Thanks, all,</div><div>Jordan</div><div><br></div><div>P.S. Since this is only changing diagnostics and the book, I don't think it needs to go through the full evolution process, but someone else from the core team can correct me.</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></div></div>