Re: [PATCH kvm-unit-tests 2/4] Introduce a C++ wrapper for the kvm APIs

Avi Kivity
2010-11-24T19:33:54Z

On 11/24/2010 09:29 PM, Jes Sorensen wrote:
> >> >
> >> Bug can still be yours but all this virtual inheritance make it much
> >> harder to understand what happens.
> >
> > No, it's easier, since there's a lot less code to chase.
> >
> > Of course, you have to learn the pattern in the language, but you do
> > this once and keep reusing this. If it's emulated in C, you have to
> > read all the code over and over again (in different uses), always on the
> > lookout to see if it's exactly the same pattern, or if some bug crept in.
>
> How does it get easier when you have to debug templated code? It is much
> harder to read the assembly and match it to the code, so no it becomes
> much harder to debug.

Oh yes, looking at compiled template heavy code is hard, especially with
aggressive inlining (quite common in template code). But what are the C
alternatives? forests of #defines, which are even harder, or abstracting
via callbacks, which isn't what you want, or simply not doing it.

Try coding something like tr1::unordered_hash<> in C. A simple
resizeable hash table that doesn't use callbacks for everything. You
can't do it.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.