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

Add proposal for @OptionSet macro #1968

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

airspeedswift
Copy link
Member

Relies on SE-0389

This will require the addition of the `@OptionSet` macro declaration to the standard library:

```swift
@attached(member)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@attached(member)
@attached(member, names: arbitrary)

```swift
@attached(member)
@attached(conformance)
public macro OptionSet<RawType>() = #externalMacro(module: "MacroExamplesPlugin", type: "OptionSetMacro")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be used as @OptionSet<UInt8> or similar. If we want to infer the raw value type, we'll need to do something differently. And I think we'll want a defaulted parameter that provides the name of the Options enum?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposal and implementation(s) use RawType, but the (non-primary) associated type is RawValue.

amartini51 added a commit to swiftlang/swift-book that referenced this pull request Jul 14, 2023
OptionSet was included in the version of the Swift standard
library that shipped with beta 1:

    https://github.com/apple/swift/blob/release/5.9-20230510/stdlib/public/core/Macros.swift#L93

However, it has since been reverted:

    swiftlang/swift#66403 (merged into 'main')
    swiftlang/swift#66404 (cherry pick to 5.9 release branch)

We should watch for it to be approved in the Swift Evolution process,
and then re-add the link (assuming it gets approved):

    https://forums.swift.org/t/63547
    swiftlang/swift-evolution#1968

Fixes: rdar://111109664
@rjmccall rjmccall added the LSG Contains topics under the domain of the Language Steering Group label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LSG Contains topics under the domain of the Language Steering Group
Projects
None yet
4 participants