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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] [POC] Allow default parameters to be added to operator functions #69051

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mininny
Copy link
Contributor

@mininny mininny commented Oct 8, 2023

This PR allows operator functions to have more than one or two parameters as long as they are default parameters, allowing something like :

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

This can be useful in scenarios when you want to pass some other parameters for other purposes like logging.

This PR changes the previous logic of checking the operator function's parameter count directly to only check the parameters that do not have default values.

This is an additive feature to the swift language and does not have backwards-breaking changes.

According to the original issue, this addition requires a swift evolution review, so this PR is for POC purposes. It still needs proper formatting and some code-level optimizations. 馃檭

Resolves #54301

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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