swiftlang/swift

[SR-11885] Allow operator functions to have extra arguments with default values

Open

#54,301 创建于 2019年12月2日

在 GitHub 查看
 (7 评论) (3 反应) (0 负责人)Swift (10,719 fork)batch import
compilerdeclarationsfeaturefuncgood first issueimprovementoperatorsswift evolution proposal needed

仓库指标

Star
 (69,989 star)
PR 合并指标
 (平均合并 8天 17小时) (30 天内合并 510 个 PR)

描述

Previous ID SR-11885
Radar rdar://problem/57711758
Original Reporter @CodaFi
Type New Feature
Votes 1
Component/s Compiler
Labels New Feature, LanguageFeatureRequest, StarterBug, StarterProposal
Assignee mininny (JIRA)
Priority Medium

md5: 210d53f6b32e8240f74a2e7677a3c698

Issue Description:

It might make sense to allow operators to have default arguments, and for those defaults to not count towards the overall arity of the operator. For example, a custom operator `<-` could have `#line` and `#file` defaults in a debug configuration. It could then check some extra invariants in a particular configuration, or do some error reporting, etc.

infix operator <-
// Still infix because it has 2 formal arguments and 1 default
public func <- (lhs: T, rhs :T, file: StaticString = #file) -> U { /**/ }

This change requires an evolution proposal.

贡献者指南