Re: C++ Frequently Questioned Answers
on Mon Nov 05 2007, Walter Bright <walter-AT-digitalmars-nospamm.com> wrote:
Jerry Coffin wrote:
In article <qOydncgL97IVsLDanZ2dnUVZ_rSrnZ2d@comcast.com>,
walter@digitalmars-nospamm.com says...
I agree it doesn't rise to the level of "proof", but then again, it is a
reasonable argument that there are serious shortcomings in the design of
namespaces. But if you don't agree, that's ok, I'll just present another
one: exception specifications (other than nothrow). As proof (!), I've
never noticed e.s. (other than nothrow) used anywhere outside of a test
suite.
I'm not sure what you're really trying to show here -- I thought we were
discussing namespaces, but it sounds like you're primarily intent on
showing that some of the "features" in the original C++ standard weren't
well thought out and haven't worked well in practice.
I'm trying to show that it's not a done deal that concepts are the
right, or even an effective, answer to the problem C++ has with
incomprehensible error messages.
Here you go again, saying that C++ feature X is there to solve problem
Y, when it isn't. Incomprehensible error messages *from deep template
instantiations* is addressed by concepts, and addressed well. That
was an important consequence we knew the concepts feature should and
would have, but it is hardly the goal of concept support in the
language.
The *goal*, if it had to be put in a few words, was to
"Support Generic Programming." If I had to elaborate, I'd say, "by
providing first-class support for things that can only be done with
hacks or documentation today, e.g. specifying the requirements of a
template, typechecking templates before they are used, overloading
based on concept conformance, and access to associated types."
It will take years of experience with concepts to determine if they
are the solution.
They are not "*the* solution to incomprehensible error messages," but
they will help a lot. Many many issues contribute to C++'s problems
with error messages, some having nothing to do with templates.
I tend to agree with that overall: exception specifications and export
(to name a couple of obvious ones) haven't shown any real utility, at
least IMO. I even use Comeau C++, one of the only compilers to implement
export, and I still don't use it in any real code.
Exception specifications are, IMO, even worse: I'm not sure export buys
a lot, but I think exception specifications are actively harmful to your
code as a rule.
Yes. Exception specifications are a technical success
In what sense?
but a semantic failure, and export is both a technical and semantic
failure.
I guess that's where we differ -- I don't see namespaces as an attempt
at modules, failed or otherwise. In fact, I have a hard time seeing
enough similarity to figure out how they could be viewed as an attempt
at modules, period. A namespace defines a scope for names -- nothing
more and nothing less.
In aiming so low, namespaces aren't much of a solution to
anything. You could just as well use prefix_name rather than
prefix::name.
Just like you could also write this->member when "member" would do.
At least that practice serves some practical purpose in C++.
We use prefixes to avoid macro name clashes, but we don't like it.
Prefixes suck. Namespaces allow expressive code without name clashes,
because local names and explicitly-imported names from other modules
can be used without qualification. As I've implied elsewhere, ADL is
the only thing that messes that up.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]