Live data from Hacker News

A proposal for named arguments for C++

open-std.org

41–50 of 62 posts

Re: A proposal for named arguments for C++

#42

I hate this idea. It just clutters the UI too much and adds noise especially if it's a UI you're familiar with. The C/C++ language is noisy enough without all this. Modern IDEs alleviate the need to be reminded inline what the values are for. On top of the fact, just about every IDE invented in the last 10 years offers code completion making this useless IMHO.

On the contrary, I would say that it cleans things up amazingly. As the language currently is, if I want to change one of the default values, I need to specify every single value up to that point. func(5,0,0,NULL,0,true,true,false,NULL,true); func(verbose: true); With named parameters, I can just specify the differences between my function call and the default values.

> func(5, 0, 0, NULL, 0, true, true, false, NULL, true);

a Windows programmer by any chance? :)

Re: A proposal for named arguments for C++

#43
post #37

Earlier quoted context omitted.

It's certainly not cross-platform, but in practice you can call C libraries on a given platform the same way, regardless of which compiler generated them.

You can do that with C++ too -- assuming they are conforming to the platform ABI. On Linux, for example, all C++ compilers can call each other's code just fine. You may be thinking of the funny situation on Windows where GCC has historically flagrantly disregarded the platform C++ ABI and implemented its own instead. I assume this decision was made as a matter of practicality: The Cygwin people didn't have the resour…

In all fairness, Microsoft breaks abi in the standard library with every single release. They do so deliberately to reserve the right to improve implementations over time.

For some evidence:

See an interesting reddit thread: http://www.reddit.com/r/cpp/comments/13zex3/can_vs2010_c_lib...

And a link to a msvc blog post which lists the sizes of various containers under various versions of MSVC: http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.a...

Note that vector on x64 shrunk from 48 to 24 bytes between VC9 SP1 and VC11. That's not an ABI, it's source compatibility.

Re: A proposal for named arguments for C++

#44

Why oh why do we need some parameters be positional and others be named. At the very least, it should just be one or the other style. Not some mix and match.

I can easily see a use for having some mandatory parameters followed by a few optional arguments. Requiring the mandatory parameters to be named adds verbosity to the code for the sake of slightly simplifying the language, which doesn't strike me as being a very C++ sort of philosophy.

Re: A proposal for named arguments for C++

#45
post #5

It is of some note that the order execution/passing of arguments to a C++ function is yet to be defined. For example, Whatdoesitdo (i++, i)

To pick nits, the order is defined: it's defined as being unspecified (Section 5.2.2).

Undefined is the opposite of defined, and threading in C++98 was `not considered` or `unaddressed`?

Re: A proposal for named arguments for C++

#46
post #37

Earlier quoted context omitted.

You can do that with C++ too -- assuming they are conforming to the platform ABI. On Linux, for example, all C++ compilers can call each other's code just fine. You may be thinking of the funny situation on Windows where GCC has historically flagrantly disregarded the platform C++ ABI and implemented its own instead. I assume this decision was made as a matter of practicality: The Cygwin people didn't have the resour…

In all fairness, Microsoft breaks abi in the standard library with every single release. They do so deliberately to reserve the right to improve implementations over time. For some evidence: See an interesting reddit thread: http://www.reddit.com/r/cpp/comments/13zex3/can_vs2010_c_lib... And a link to a msvc blog post which lists the sizes of various containers under various versions of MSVC: http://blogs.msdn.com/b/…

Its worse then that! The ABI is different for debug and release version of the same library resulting in crazy, crazy bugs.

Re: A proposal for named arguments for C++

#47

I hate this idea. It just clutters the UI too much and adds noise especially if it's a UI you're familiar with. The C/C++ language is noisy enough without all this. Modern IDEs alleviate the need to be reminded inline what the values are for. On top of the fact, just about every IDE invented in the last 10 years offers code completion making this useless IMHO.

Nope. Imagine that you change a function prototype:

    void drawBox(int X,int Y,int W,int H);

    void drawBox(int TL,int TR,int BL,int BR);
Having an extra safety for mature code offers an immediate protection, in a much more accessible fashion then competing ideas like 'concepts'.

Re: A proposal for named arguments for C++

#48

Please stop adding features to C++ and standardize an ABI already. The lack of an ABI is why it's impossible to call C++ libraries without an entire C++ compiler – and it generally requires generating mountains of wrapper code a la SWIG – which is then called with the C ABI. The lack of an ABI is why dynamic libraries use C for writing extensions instead of C++: C++ can literally only be called by C++ (and in fact on…

A proposal for C++ to stop being such a moving target.

Luckily, this has already been proposed: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n402...

I really hope it makes it into the language. A stable API for external functions and whatever ABI you want for internal functions.

Re: A proposal for named arguments for C++

#49

Please stop adding features to C++ and standardize an ABI already. The lack of an ABI is why it's impossible to call C++ libraries without an entire C++ compiler – and it generally requires generating mountains of wrapper code a la SWIG – which is then called with the C ABI. The lack of an ABI is why dynamic libraries use C for writing extensions instead of C++: C++ can literally only be called by C++ (and in fact on…

There is an ABI most C++ vendors conform to already:

  http://www.swag.uwaterloo.ca/acd/docs/ItaniumC++ABI.htm
Almost every major vendor has been working towards this for a long time now.

Microsoft of course remains "special".

Regardless, the C++ standards committee did look at creating a portable C++ ABI in May 2014:

  https://isocpp.org/blog/2014/05/n4028

Re: A proposal for named arguments for C++

#50

Please stop adding features to C++ and standardize an ABI already. The lack of an ABI is why it's impossible to call C++ libraries without an entire C++ compiler – and it generally requires generating mountains of wrapper code a la SWIG – which is then called with the C ABI. The lack of an ABI is why dynamic libraries use C for writing extensions instead of C++: C++ can literally only be called by C++ (and in fact on…

Oh, of course they cant do these simultaniously, right?

Or features are wrong? What's exactly wrong with this feature? Its improvement.

Post reply on HN