[swift-evolution] [META] Re-invigorating the compiler directive discussion

Step Christopher schristopher at bignerdranch.com
Sun Mar 13 14:50:26 CDT 2016



> El mar 13, 2016, a las 12:57 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> escribió:
> 
> 
>>> On Mar 12, 2016, at 9:25 PM, Step C <schristopher at bignerdranch.com> wrote:
>>> SE-0020 added #if swift to enable code to compile with specific versions of the Swift language. This proposal introduces several further compile-time configuration, adding configuration tests for x, y, z, and w.
>>> 
>> I assume x, y, z, and w are intended to be filled in once the list has settled. 
> 
> Yes.
> 
> This is still first draft-y.
> 
>>> Swift also misses a built-in #if debug test. Although you can specify command-line flags using -D <#flag#> (e.g. -D debug) and test in-code (#if debug), there's no consistent system-supplied way to perform this test.
>>> 
>> What do you mean by "this test"? Testing for a built-in configuration (debug) without needing customization?
>> 
>>  Also FWIW I am ok with the custom flag approach.( In fact it just occurred to me that I can use the custom flags approach to check for test targets too - nice! )
> 
> "There's no consistent system-supplied way to differentiate code meant solely for debug builds".
> 
> Better?

Yes. 

> 
>>> #if imports(UIKit) tests for framework support, differentiating, for example, Mac code from iOS and tvOS code.
>> Am I reading it right that this would import the framework if the test succeeds?
> 
> I was not intending that this do the import, but test whether the framework/module (probably change this to module) *could* be imported.
> 
`if importAvailable(UIKit)` 
`if moduleAvailable(UIKit)`
`if canImport(UIKit)` ?

It should say module, good point. 

>> 
>>> #if target(simulator) and #if target(device) represent a common categorization requirement, such as Metal, Keychain, and AVFoundation Camera code. 
>>> #if target(32bit) and #if target(64bit) tests for 32 and 64 bit architecture families. 
>>> #if target(bigendian) and #if target(littleendian) tests for big and little endianness.
>>> #if config(debug) tests for debug builds. 
>> Wondering if it is better to cover these all in one proposal or chunk them up. Wouldn't want this to become an omnibus proposal and get bogged down. But it makes sense to discuss many of these together. 
> 
> I put out a query on-list asking for clarification from the core team. Have not heard a peep. If this gains any momentum, I suspect someone will chime in.
> 
> -- E
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160313/d9c5356d/attachment.html>


More information about the swift-evolution mailing list