Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ask for a small addition? (syntax of pure virtual functions)

In the current C++0x draft I've noticed they introduced some new explicit keywords to highlight expected behaviors (great move!).

Examples: defaulted/deleted functions (= default and = delete), the new nullptr constant, the explicit keyword usable also for conversion operators, ...

So I expected to see also a = pure syntax for pure virtual functions.

Instead the ugly (IMHO, of course) = 0 thing still exists.

Ok, I can use a #define pure 0 (and sometimes I do that), but I think coherency/consistency should be definitely a goal for a standard. Moreover I know it's just a sort of ultra-pedantic request, but = 0 was indeed one of my least favorite part of C++ (euphemism)...

My questions:

  • I know, the new standard is feature-complete, but is it still possible to ask for this small pedantic addition, even just as a "required macro" thing?
  • if the answer is positive, how? (any committee member around?)
  • am I just a bit too pedantic (or wrong) for asking this addition? what do you think about the current syntax of pure virtual functions?
like image 394
Gian Paolo Ghilardi Avatar asked May 12 '09 12:05

Gian Paolo Ghilardi


People also ask

What Is syntax of pure virtual function?

¶ Δ A pure virtual function is a function that must be overridden in a derived class and need not be defined. A virtual function is declared to be “pure” using the curious =0 syntax.

When we do make a virtual function pure Whatare the implications making the function as pure virtual function?

A pure virtual function makes it so the base class can not be instantiated, and the derived classes are forced to define these functions before they can be instantiated. This helps ensure the derived classes do not forget to redefine functions that the base class was expecting them to.

What is the correct way to define the function display () as a pure virtual function in C++?

A pure virtual function is a virtual function in C++ for which we need not to write any function definition and only we have to declare it. It is declared by assigning 0 in the declaration. An abstract class is a class in C++ which have at least one pure virtual function.

Can you define a pure virtual function in base class?

A pure virtual function is a member function of base class whose only declaration is provided in base class and should be defined in derived class otherwise derived class also becomes abstract. Classes having virtual functions are not abstract. Base class containing pure virtual function becomes abstract.


1 Answers

That's not a small pedantic change. Introducing a new keyword is one of the biggest changes you can ask for. It is something they try to avoid almost at any cost. Think of all the code that uses the word "pure", which would break.

In general, their guideline is to only add things to the language that could not be done before. A pure keyword wouldn't enable anything new (unlike the nullptr keyword, which enables better type checking, for example), so expect it to have a very low priority. Keep in mind that anything they do is basically maintenance work. The #1 goal is to avoid breaking the language (or existing code that uses it). Any features that are added on are only added if it can be done without breaking backward compatibility.

However, the committee is more or less an open forum. Browse around their website, and you should be able to find a few email addresses. OR use the comp.std.c++ newsgroup.

I believe their meetings are open as well, so you could just gatecrash the next one. ;)

like image 192
jalf Avatar answered Sep 29 '22 14:09

jalf