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

[fs.op.funcs] Remove empty parens when referring to functions by name #7622

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

jwakely
Copy link
Member

@jwakely jwakely commented Feb 7, 2025

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The specification style guidelines expressly say that "call X" is fine, where X has parentheses (= is an expression). It's just "calling the function Y" needs to have parentheses removed.

Maybe we want to fine-tune the rules a little, but the changes proposed here don't seem to be "obviously in line" to me.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 8, 2025
@jwakely
Copy link
Member Author

jwakely commented Feb 8, 2025

The specification style guidelines expressly say that "call X" is fine, where X has parentheses (= is an expression).

Yes but it has to be a valid expression, so "calls create_directory()" is wrong, because it needs arguments.

It's just "calling the function Y" needs to have parentheses removed.

I don't see a distinction between "calls f()" and "calling the function f()" in the case where f() is not a valid expression. They're both just "naming" a function, so should not have parentheses.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 8, 2025
@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 10, 2025

So, we accept "calls f(1, 2, 3)" (instead of "invokes f with arguments 1, 2, 3"), but if we don't give arguments, then it must be "calls f", not "calls f()", right? We can make that clearer in the wiki, but that seems like a good rule.

@jwakely
Copy link
Member Author

jwakely commented Feb 10, 2025

Yes, that's what I thought the rule was. I see that the wiki is actually ambiguous and can be interpreted differently, but that different interpretation seems useless to me. A rule that allows "call sin()" but not "calling the function sin()" seems like a completely pointless rule. You cannot "call sin()" because that's not the name of a function, and calling one of the overloads of sin would require an argument to make it a valid expression.

@jwakely
Copy link
Member Author

jwakely commented Feb 10, 2025

If we do want to allow "call sin()" then IMHO we might as well strike the rule entirely, and just allow empty parens on any function name! (This would match POSIX, which intentionally puts empty parens when referring to any function, but I guess that can be argued to be OK in ISO C89 where fopen() declares a function without saying what its parameters are).

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 10, 2025

Let's fix the wiki instead!

@jensmaurer
Copy link
Member

"call sin()" should not be valid. If the wiki needs fixing, so be it.

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 11, 2025

Actually, is the wiki really ambiguous? It says (emphasis mine),

"""
When we say "Calls blah", blah should be an expression that results in a function call. Eg, "calls operator new(size)" or "calls `current_exception() and stores the returned value".
"""

and since sin() is not an expression that results in a function call, it already doesn't seem to be allowed? We can certainly clarify the wording a bit, but the intention seems clear already.

@jwakely
Copy link
Member Author

jwakely commented Feb 11, 2025

Yeah I checked it again yesterday and cross-referenced it with #2150, and the wiki seems pretty clear. And all the changes in this PR are cases where foo() is not a valid expression, and does not disambiguate an overloaded function by naming the foo(void) overload.

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 11, 2025

OK, great, thanks!

@tkoeppe tkoeppe merged commit 4e026ec into cplusplus:main Feb 11, 2025
2 checks passed
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.

3 participants