-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Optional argument names (unused arguments) #476
Comments
Is there a reason to treat function parameter lists differently from other pattern-matching contexts in this respect? If not, it seems like the syntax should be |
Presumably function parameters have names in other contexts. For example, if you're implementing an interface with an API:
And you have an implementation that doesn't use
May raise the question of what the unused parameter was. |
In Google C++ style, the equivalent comment is:
|
My high-level thoughts here:
I had originally been fond of just prefixing identifiers with But I can see that being viewed as excessively clever. I don't think this pattern is common enough to merit burning punctuation (already a precious commodity) in the lexical space except for I think the most promising structure then is: So I think I prefer |
Assuming I understand correctly, we end up with:
I think this offers a nice structure. |
Noting here too, |
The leads chatted about the options presented here a while back and I wrote up the candidate resolution that I think we all were happy with, although to be honest it was some time ago so sorry if I've misremembered this. Basically, we were actually pretty happy with just have distinct syntax between unused-but-named patterns vs. unnamed-and discarded patterns. The result would be:
What do folks think? Also, did I recall this right @KateGregory and @zygoloid? |
Not hearing any concerns, let's call this decided. |
Filed #1996 to track the need for a proposal here, as part of switching to labels for leads question tracking. |
For functions, should names be optional? If so, what is the syntax for that?
In C++, both of the following are allowed:
In Carbon, we're not doing
/*
comments, so that's out.Things we discussed are:
I've also suggested making
unused
a keyword, as inunused int i
.The text was updated successfully, but these errors were encountered: