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

[SR-6479] Syntactic sugar: extension P where Self: Z should be extension Z & P #49029

Open
swift-ci opened this issue Nov 27, 2017 · 5 comments
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-6479
Radar None
Original Reporter revolucent (JIRA User)
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 97d3df82b940410296d7de2d995e756e

Issue Description:

Instead of saying…

extension P where Self: Z {
  // blah blah
}

It would be nice to be able to say…

extension Z & P {
  // blah blah
}
@belkadan
Copy link
Contributor

There are a few cases where the two behave differently. @slavapestov might remember better than me.

@swift-ci
Copy link
Collaborator Author

Comment by Gregory Higley (JIRA)

Well, right now extension Z & P is completely disallowed. It produces a compiler error. I propose to repurpose it as syntactic sugar for extension P where Self: Z. It seems intuitively correct.

@belkadan
Copy link
Contributor

Yes, and it isn't. There are a few cases where the two behave differently. More specifically, there's a distinction between

extension P where Self: Z

and

extension Z where Self: P

but I can't remember when it comes up. It's pretty rare.

@belkadan
Copy link
Contributor

There could be a fix-it, at least, but only if it's obvious what you meant to extend.

@swift-ci
Copy link
Collaborator Author

Comment by Gregory Higley (JIRA)

I thought about the distinction you mentioned, but I can't think of a case where it would occur. If that's true, it'd be a real shame. If there is a distinction, the existing syntax is probably best, because it's clearer, though one path forward might be to eliminate the distinction and then add my tasty syntactic sugar. 🙂

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement
Projects
None yet
Development

No branches or pull requests

2 participants