C++ Logo

std-proposals

Advanced search

Making parameter names clearer than func(true, false);

From: Jonny Grant <jg_at_[hidden]>
Date: Sat, 6 Jul 2019 14:13:17 +0100
Hello
My first post!

*Parameter Names*

Don't you just hate it when you're reading code that looks like this and
no idea what those parameters are ?

func(true, false);


This is the function declaration - but it's a pain to go and find that:
void func(bool debug, bool log);

With this proposal, allowing inclusion of the parameter names makes it
clear:
func(debug=true, log=false);

What do you think?

Cheers, Jonny

ps. read the other proposals, but I feel this is simpler, clearer

http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0671r2.html

I don't think passing parameters in any order is a good idea though,
that makes it harder to identify any missing parameters (or accidentally
default initialized parameters)
https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/

This one is the same/similar proposal as mine, so would support this style
https://marcoarena.wordpress.com/2014/12/16/bring-named-parameters-in-modern-cpp/


Received on 2019-07-06 08:15:13