Re: Idiots
In article <49WdnW6R0tMzb1jWnZ2dnUVZ8lCdnZ2d@giganews.com>,
leigh@i42.co.uk says...
[ ... ]
I was thinking more of the template containers and allocators rather than
the C runtime subset which is antiquated yes. std::size_t is used
extensively. You should use a container's public typedefs in client code
(i.e. size_type).
Yes, but it all goes back to size_t, which itself goes back to
C89/90. Basically, they bend over backwards to allow (for example)
::operator new to be a really simple wrapper around malloc, and
::operator delete an even simpler wrapper around free.
2) Don't use abstract interfaces (as they advocate against using
public virtual functions).
Nonsense! You can have abstract interfaces without public virtual
functions. At least AFAIK, this was first advocated by Herb Sutter,
who certainly is NOT an idiot (e.g. he is on the standard committee,
so he helped design a fair amount of what you're treating as
exemplary in your previous point).
Not nonsense, this what I mean by an abstract interface:
struct abstract_interface
{
virtual void foo() = 0;
virtual void bar() = 0;
};
At least start by using terminology people will understand -- that's
an abstract base class.
If you define "abstract interface" to require public virtual
functions, and then complain that you can't create them without
public virtual functions, all you're doing is stating a meaningless
tautology. Using "abstract interface" without attaching the special
meaning of requiring public virtual functions, yes, you can certainly
create abstract interfaces without using public virtual functions.
Regardless of whether you agree with the idea, however, it's not a
product of simple idiocy, or anything like it. Quite the contrary, if
I were to find a fault with it, it's that it's a result of a little
too much abstract thinking that produced a rather over-engineered
solution to a problem that's ultimately fairly rare and minor.
[ ... ]
Wrong, the C++ standard library does advocate, nay, require
inheritance, look at std::iterator and std::binary_function.
First, you were talking about containers -- I certainly did not claim
that no part of the standard library uses inheritance at all. I said
that none of the standard _containers_ did so. I also said that if
Alexander Stepanov were designing them again today, the evidence seem
to suggest that he still wouldn't use inheritance. I believe the
evidence in _Elements of Programming_ and a couple of interviews that
are available online (one of which I already cited) support that
point quite well.
Obviously, I'm only guessing though -- it's always possible that this
morning he woke up and decided to reverse the position he's held for
years. If he has, I probably wouldn't know about it.
Interface augmentation is quite valid, Bjarne Stroustrup advocates
it in TC++PL.
You're conflating two rather different things here. At least as far
as I've seen, nobody has said interface augmentation, as a basic
idea, is particularly wrong. What I've seen people say is that the
standard container classes don't have (for an obvious example)
virtual destructors, so public inheritance from them must be handled
with care that's so extreme that you're frequently better off
considering other options.
--
Later,
Jerry.