swiftlang / swift-book

The Swift Programming Language book
Apache License 2.0
1.76k stars 162 forks source link

Access Control — Mention macros in the intro #229

Open tadbyt opened 11 months ago

tadbyt commented 11 months ago

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/accesscontrol

Description

This subsection doesn't reflect the changes to Swift with respect to macros and packages.

Correction

Reword the first sentence in the first paragraph to: Access control restricts access to parts of your code from code in other types, source files, modules and packages. Add the following sentence to the end of the second paragraph: However, both macro declarations and their associated implementation types must have public access since the code that declares a macro is in a different module than that that implements it.

amartini51 commented 10 months ago

This appears to already be covered in the Macros chapter, which is the appropriate place for this detail anyhow.

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/macros#Macro-Declarations

Macros are always declared as public. Because the code that declares a macro is in a different module from code that uses that macro, there isn’t anywhere you could apply a nonpublic macro.