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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/24/2010 07:06 PM, Jes Sorensen wrote:
On 11/24/10 17:59, Avi Kivity wrote:
>  On 11/24/2010 06:51 PM, Jes Sorensen wrote:
>>  Right we need good design for our C code, which we are lacking to a
>>  large extend. However that has nothing to do with the language, that has
>>  to do with the developers.
>
>  I'm sure patches will be welcome.
>
>  C++ doesn't enforce good design.  But it allows a good design to be
>  enforced.

Sorry but that is utterly and completely bogus! The enforcement is only
as good as the developers and maintainers make it,

  class File {
  public:
      virtual ~File() {}
      virtual void read(...) = 0;
      virtual void write(...) = 0;
  };

Anyone wishing to implement this interface is forced to implement read and write methods (callbacks) with exactly the right signature. The compiler will complain if they don't. So if File is a good interface, we can make the compiler force people to use it correctly.

We can emulate this in C with ->ops-> things, but that's just boilerplate and more places for people to get things wrong, or lazy and take shortcuts.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux