[Please do not mail me a copy of your followup]
Manfred <non...@invalid.add> spake the secret code
<olfrfh$1h0g$
1...@gioia.aioe.org> thusly:
>'Cause the thing is closely related with code generation, and I recalled
>things like an 'interface' metaclass being considered, and then
>discarded, because, even if they are of wide use:
>They are typically intentionally designed to be very thin, not to pose
>excessive overhead on the project as a whole. The advantage of having
>them generated is therefore very limited - since they are designed to be
>thin, it is trivial to write an interface class in plain C++.
I agree with your analysis ('interface' is thin), but disagree with
your conclusion.
I have seen lots of people write 'interface' classes where they forget
the virtual d'tor or implementation methods start leaking into the
interface, or they have other concrete methods in the interface.
Having a compiler enforce what it means for something to be an
interface is a solution to all these problems that arise from a lack
of self discipline.
If we considered it sufficient to rely on self discipline alone, then
we would just use C. But we don't, we value the extra checks that the
type system of C++ can provide and we lean on that to prevent
ourselves from getting sloppy in this regard.
I found the more compelling examples to be in his YouTube video, which
I encourage you to watch if you've only looked at the proposal and the
blog post. The flags enum example was particularly useful. He also
shows how it cleans up a whole bunch of crufty things like having to use
IDL compilers or the Qt moc compiler, making them entirely unnecessary
without imposing costs on people who don't use these facilities.
Furthermore, having them be testable libraries that can be distributed,
tested, improved upon and ultimately standardized via the library working
group is much better for the community than attempting to standardize
them through the language working group in the standards body.
One advantage of the approach advocated by Herb Sutter is that if you
don't like these metaclasses, you're not paying for them in any way.
Even if the standard library starts using them in conjunction with
concepts, I can't see that any of your code would be affected by their
use. If you provide implementations that are different from the
default supplied by a metaclass, it doesn't change your code.