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

[SUGGESTION] Named (and order independant) optional parameters #202

Closed
ILoveGoulash opened this issue Jan 6, 2023 · 4 comments
Closed

Comments

@ILoveGoulash
Copy link

ILoveGoulash commented Jan 6, 2023

Hello,

I should have nothing to say about the desirability of said feature, anyone who has ever felt the need for more than one optional parameter in C++ or used a language with them (Common Lisp, Julia, Python, Ruby, etc...) knows how it can clean up APIs and increase readability of call sites.
A quick web search shows the heavily boilerplate filled nature (and order restriction for the C++20 method) of the usual workarounds:
https://rosettacode.org/wiki/Named_parameters#C++
https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/
https://pdimov.github.io/blog/2020/09/07/named-parameters-in-c20/

This "suggestion" isn't as much a suggestion as a "was it ever discussed and rejected for some reason (e.g. ABI problems, C++20 workaround considered decent enough, no agreement on syntax, etc...)?" because I didn't manage to find anything in the closed/open issues.

@jcanizales
Copy link

Coincidentally it was mentioned recently as an aside of another issue: #193 (comment) (at the end of that comment).

@filipsajdak
Copy link
Contributor

I was sure that I had seen that somewhere. Thank you for finding it!

@ILoveGoulash
Copy link
Author

I see, no wonder I didn't find it.

@hsutter
Copy link
Owner

hsutter commented Jan 9, 2023

@ILoveGoulash Thanks for the ping. Named arguments are a possible future direction as mentioned in the #193 (comment) link above, search for "designated initializers" (sorry that the comment it requires search, it got to be a long essay-length comment).

Meta comment to everyone: When opening suggestions, please do follow the Suggestion template and include the information it asks for. Thanks! Much appreciated.

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

No branches or pull requests

4 participants