Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting Contexts for API Availability between Language Guide and Language Reference #276

Open
tadbyt opened this issue Feb 26, 2024 · 0 comments

Comments

@tadbyt
Copy link
Contributor

tadbyt commented Feb 26, 2024

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/controlflow#Checking-API-Availability
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/statements#Availability-Condition

Description

In the Language Guide Checking API Availability subsection, at the beginning of the third paragraph the text states:

You can use an availability condition in an if or guard statement to conditionally execute a block of code, depending on whether the APIs you want to use are available at runtime.

All subsequent text and examples in the subsection support this.

In the Language Reference Availability Condition subsection, the first paragraph reads:

An availability condition is used as a condition of an if, while, and guard statement to query the availability of APIs at runtime, based on specified platforms arguments.

The grammar is sufficiently vague as to permit an API availability check in these and many other locations, where it doesn't appear to be semantically allowed.

Xcode doesn't yield diagnostics when an API availability is given in a while statement, but does for a repeat-while statement.

Correction

Reword the first sentence in the Language Guide Checking API Availability subsection to read:

You can use an availability condition in an if, guard, or while statement to conditionally execute a block of code, depending on whether the APIs you want to use are available at runtime.

An example shouldn't be necessary as using an API availability check is an unlikely occurance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant