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-11885] Allow operator functions to have extra arguments with default values #54301

Open
CodaFi opened this issue Dec 2, 2019 · 7 comments · May be fixed by #69051
Open

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

CodaFi opened this issue Dec 2, 2019 · 7 comments · May be fixed by #69051
Labels
compiler The Swift compiler itself declarations Feature: declarations feature A feature request or implementation func Feature → declarations: Functions good first issue Good for newcomers improvement operators Feature: operators swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@CodaFi
Copy link
Contributor

CodaFi commented Dec 2, 2019

Previous ID SR-11885
Radar rdar://problem/57711758
Original Reporter @CodaFi
Type New Feature
Additional Detail from JIRA
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.

@beccadax
Copy link
Contributor

beccadax commented Dec 6, 2019

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added improvement swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal and removed new feature StarterProposal labels Nov 11, 2022
@mininny
Copy link
Contributor

mininny commented Oct 8, 2023

This issue is fairly old and I'm not sure if it's worth bringing back, but it doesn't seem complex so I've come up with a POC implementation. #69051

If this requires a swift evolution proposal, I want to go through one as it's my first SE proposal.

Any guidance on how to get this through would be very appreciated! 😄

@AnthonyLatsis AnthonyLatsis added operators Feature: operators declarations Feature: declarations func Feature → declarations: Functions labels Oct 9, 2023
@AnthonyLatsis
Copy link
Collaborator

Yeah, this must go through the Swift evolution process.

@mininny
Copy link
Contributor

mininny commented Oct 9, 2023

Thanks for weighing in always! @AnthonyLatsis

I see, I've drafted up a proposal document here: https://github.com/mininny/swift-evolution/blob/default-arguments-in-operator-functions/proposals/NNNN-default-arguments-in-operator-functions.md.

Should I get this reviewed by anybody, or is it fine to post it in the forums as a pitch?

@AnthonyLatsis
Copy link
Collaborator

or is it fine to post it in the forums as a pitch

Yes, I recommend initiating a draft pull request and referring to it in the pitch so that you can refine the proposal in the open without having to continuously update the root post throughout the discussion. The guide to proposing features is here.

@joshua-arnold
Copy link

Hey! This would be super useful to have for testing-related libraries. Are you still working on this @mininny? Thanks!

@mininny
Copy link
Contributor

mininny commented Jul 17, 2024

Hey! This would be super useful to have for testing-related libraries. Are you still working on this @mininny? Thanks!

Hi @joshua-arnold , thanks for the nudge! I did complete the POC implementation and evolution proposal last year, but haven't had the time to put this up as a pitch and forgot about it. I'll go ahead and create one 😄 (created here: https://forums.swift.org/t/pitch-allow-operator-functions-to-have-extra-arguments-with-default-values/73236)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler itself declarations Feature: declarations feature A feature request or implementation func Feature → declarations: Functions good first issue Good for newcomers improvement operators Feature: operators swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants