[swift-evolution] [Proposal] Swift 2.2: #if swift language version
Félix Cloutier
felixcca at yahoo.ca
Sat Dec 19 16:17:57 CST 2015
I don't really like how different this makes "#if swift" from "#if <anything else>". To me, that would be a violation of the principle of least astonishment.
> Le 19 déc. 2015 à 17:08:13, David Farler via swift-evolution <swift-evolution at swift.org> a écrit :
>
>
>
>> On Dec 19, 2015, at 13:48, Michel Fortin <michel.fortin at michelf.ca> wrote:
>>
>>> 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 michel
>
> Yes, that's right, it is a change but only for this new directive because one of its uses is to control exposure to syntax or API changes. Other build configurations such as 'os' and 'arch' will be unaffected.
>
> I myself wouldn't want build configs to act like the C preprocessor, although that kind of change is probably out of this proposal's scope anyway, IMO.
>
> David
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151219/cc3f5ce9/attachment.html>
More information about the swift-evolution
mailing list