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-8278] Syntax to disambiguate operators #50809

Open
swift-ci opened this issue Jul 17, 2018 · 1 comment
Open

[SR-8278] Syntax to disambiguate operators #50809

swift-ci opened this issue Jul 17, 2018 · 1 comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8278
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: c6afa3d80664e636a7dd953616f58088

relates to:

  • SR-895 Cannot do a qualified import of an operator
  • TF-1065 Consider disallowing qualified operators in @transpose

Issue Description:

I propose to borrow Haskell's syntax for operator disambiguation when the same operator is declared in two different modules and the compiler cannot figure out which one to use contextually. Given the made-up operator %! occurring in modules Foo and Bar, we could say

import Foo
import Bar

let x = 3 (Foo.%!) 4
let y = 17 (Bar.%!) 99

Perhaps in Swift the parentheses are not necessary.

The general workaround for this is that there should be an "ordinary" function declared for every operator, so that it can be used in places where the compiler gets confused. This is the practice I follow, but being able to disambiguate operators in this way would be very useful.

@belkadan
Copy link
Contributor

Definitely a worthwhile issue. Would need to go through the Swift Evolution Process.

@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