[swift-evolution] [Proposal] Swift 2.2: #if swift language version

Michel Fortin michel.fortin at michelf.ca
Sat Dec 19 15:48:57 CST 2015


Le 18 déc. 2015 à 15:22, David Farler via swift-evolution <swift-evolution at swift.org> a écrit :

> #if swift("2.2")
>  print("Hello")
> #else
>  this code will not parse or emit diagnostics
> #endif

This is a change from how the #if directive currently works. Currently, it's a syntax error to write this:

	#if DEBUG
	@abaraka func test() {}
	#endif

even if DEBUG is false because the content is parsed regardless and @abaraka is not a valid attribute. The syntax inside the #if/#endif must be valid for the parser.

So this proposal implies a change in how #if is parsed. Should it works like the C preprocessor?

-- 
Michel Fortin
michel.fortin at michelf.ca
https://michelf.ca



More information about the swift-evolution mailing list