Skip to content

[SR-8278] Syntax to disambiguate operators #50809

@swift-ci

Description

@swift-ci
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compilerThe Swift compiler itselffeatureA feature request or implementationimprovement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions