I am not sure if someone has mention it already but i think named function arguments might be a helpful extension.
The implementation should basically be the same as in python.
void my_funtion(int p1, int p2) ;
int main() {
my_funtion(p2=123, p1= 321);
}
I think most of us are already very familiar with the feature and the benefits are clear.
I see a special use case when it comes to simple data structs. For example I am in the process of writing a little ntuple library. This library can generate ntuple with some template magic.
example:
auto my_tuple = nt::ntuple{
subdetector = i ,
sector{123},
sector1 = std::string("asd"),
axis = "4655",
plane() = 1231,
ax_maker(ex1) = 789 // ax_maker is a macro that generates a new axis on name "ex1" in-place
};
assert(my_tuple.sector== 123);
assert(my_tuple.sector1 == "asd");
However this only works if the term subdetector (sector/sector1/axis/plane ) is already defined previously.
I believe that for clarity and expressing intent, named function arguments are an essential feature that any language succeeding C++ must incorporate. While I recognize the complexity of lifetime considerations, I feel that the potential benefits make it a worthwhile endeavor.
PS: Thanks for the Great talk(CPPCON) and this wonderful project.
DISCLAIMERS TO SET EXPECTATIONS: I'm generally against language feature requests/changes unless they can be shown to improve simplicity, safety, or toolability in a quantifiable way. So:
Please limit suggestions to quantifiable improvements to C++ simplicity, safety, or toolability. Quantifiable means that there is some kind of measurable data that helps motivate the change and measure success. Two of the big ones that will get my attention are eliminating vulnerabilities and eliminating guidance, so use those below please.
Please do not suggest syntax changes. I accept there are hundreds of opinions and everyone will prefer something a little different. Syntax isn't the big thing, fixing semantics is -- reducing concept count, increasing toolability, are the big payoff.
Please do not suggest things that amount to personal taste. I accept there are hundreds of personal tastes and everyone will prefer something a little different. For example, established stakes in the ground include that this declaration syntax is going to be left-to-right, and it's going to use : for every declaration and only for declarations.
Will your feature suggestion eliminate X% of security vulnerabilities of a given kind in current C++ code? If yes, please be specific about the classes of bugs that would go away, with an example or two (especially a link to a real CVE or two).
Will your feature suggestion automate or eliminate X% of current C++ guidance literature? If yes, please be specific about what current good guidance this helps make the default, and/or what guidelines we would no longer need to teach/learn or that would be simplified and how, with an example or two (especially a link to a real "Effective C++" or "C++ Core Guidelines" guideline or two). For ideas, you can refer to my CppCon 2020 talk starting at 10:31 where I summarize a categorized breakdown based on over 600 C++ guidance literature rules I cataloged and analyzed.
Describe alternatives you've considered.
There's nearly always more than one way to improve something. What other options did you consider? Why is the one you're suggesting better than those?
Hi,
I am not sure if someone has mention it already but i think named function arguments might be a helpful extension.
The implementation should basically be the same as in python.
I think most of us are already very familiar with the feature and the benefits are clear.
I see a special use case when it comes to simple data structs. For example I am in the process of writing a little ntuple library. This library can generate ntuple with some template magic.
example:
However this only works if the term subdetector (sector/sector1/axis/plane ) is already defined previously.
I believe that for clarity and expressing intent, named function arguments are an essential feature that any language succeeding C++ must incorporate. While I recognize the complexity of lifetime considerations, I feel that the potential benefits make it a worthwhile endeavor.
PS: Thanks for the Great talk(CPPCON) and this wonderful project.
DISCLAIMERS TO SET EXPECTATIONS: I'm generally against language feature requests/changes unless they can be shown to improve simplicity, safety, or toolability in a quantifiable way. So:
:
for every declaration and only for declarations.Will your feature suggestion eliminate X% of security vulnerabilities of a given kind in current C++ code? If yes, please be specific about the classes of bugs that would go away, with an example or two (especially a link to a real CVE or two).
Will your feature suggestion automate or eliminate X% of current C++ guidance literature? If yes, please be specific about what current good guidance this helps make the default, and/or what guidelines we would no longer need to teach/learn or that would be simplified and how, with an example or two (especially a link to a real "Effective C++" or "C++ Core Guidelines" guideline or two). For ideas, you can refer to my CppCon 2020 talk starting at 10:31 where I summarize a categorized breakdown based on over 600 C++ guidance literature rules I cataloged and analyzed.
Describe alternatives you've considered. There's nearly always more than one way to improve something. What other options did you consider? Why is the one you're suggesting better than those?