D
David Thompson
They could have made string literals const while allowing implicit
conversion of const char * to char *,
That would have been much _more_ dangerous; it would allow undetected
screwups even for program(mer)s that went to the effort of using
(adding) the new 'const' qualification. Even if you limited it to
occurring during decay, const char [] to char *, as C++ does.
C++ doesn't actually solve the problem for C strings, and really
can't. What it does do is provide a whole new set of std::*string's,
with lots of new features including correct constificationosity.
and make the return type of
strchr, strstr etc. const char *, as in C++.
No, in C++ there are BOTH const and nonconst versions, overloaded.
Which C++ can easily do because it already needed and had overloading.
C89 didn't, and the committee apparently judged that adding it just
for this would have been overkill. Although a decade later they did
require effective overloading, at least of builtins, for <tgmath.h>.
- formerly david.thompson1 || achar(64) || worldnet.att.net