Re: Standard Versus Non-Standard C++
On Sunday, July 1, 2012 7:15:45 AM UTC-5, Zeljko Vrba wrote:
{ Please avoid useless quotes, but do provide the minimum
necessary to establish context -mod }
On 2012-07-01, Le Chaud Lapin wrote:
Also, a question for you: many C++ projects can be compiled with
MSVC and GCC, i.e., they are syntactically correct ISO C++ programs.
Yet, they rely on behavior that is UB according to the standard, but
which both compilers define in a useful way. Since code exhibiting
UB at run-time is technically not "valid C++ code", should the
authors of such projects be allowed to say that they are coding in
C++?
Because such UB code would be, in fact, valid C++. About this code,
the standard would say: "This code is will be compiled by a conforming
compiler, but the behavior would be undefined.
When criticizing somebody for saying "C++" when they actually mean
"C++ as compiled by compilers X,Y on platforms A,B,C", why do you
(arbitrarily) draw the line at minor syntax extensions, use of which
is fully avoidable [at the cost of more complexity/verbosity]?
Because the extensions are not minor. In some cases, they are
wholesale replacements for concepts that C++ already offers.
To play devil's advocate, one could argue that in my own programming,
I contradict my argument: I never use STL, ever. I never use set<>,
list<>, vector<>, or string. But I do use Set<>, List<>, Vector<>, and
String, and I claim that my new classes are "C++. There are two
reasons that I can legitimately make this claim.
1. An ISO-compliant compiler will compile my code.
2. If I were an instructor teaching C++ to beginners, and my students
were aware of the existence of a standard library that included
things like set<>, vector<>, list<>, etc...I would tell them that
the classes that I am recommending that they use: Set<>, List<>,
Vector<>, String; are not the classes that they heard about from
the standard library, even though the names are the similar, and I
would issue copious warnings that they should not expect such code
to run anywhere my library binary code does not exist, which is
pretty much everywhere.
I would not tell them when they employ my library, "You are still
programming in the standard library." This is what is sometimes
stated by Microsoft when Microsoft uses non-standard extensions
like "^". They say, "It is still C++.", and it looks like C++,
because the keywords are the same, but the semantics of those
keywords have been changed in subtle ways. Here is what they did
to 'const' and 'volatile':
"The semantics of const and volatile are changed. const (frequently
used in C++ code) is only an optional modifier (modopt) in the CLI
bindings, and therefore can be ignored by compilers and other
tools, whereas volatile (rarely used in C++ code) is a required
modifier (modreq)."
See:
http://www2.research.att.com/~bs/uk-objections.pdf
-Le Chaud Lapin-
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]