[openbeos] Re: !RE: Drivers in C

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: openbeos@xxxxxxxxxxxxx
  • Date: Thu, 17 Jan 2002 20:01:06 +0100 (MET)

> There are three sources of inefficiency for C++. First is exception
> handling, which can be disabled during compilation. Second is 
> abstraction,
> where some constructs such as accessor functions may not be handled
> efficiently by the compiler. This can be avoided by careful design of 
> the
> driver model. The other source of inefficiency is programmer 
> carelessness.
> This can be avoided by applying good practices as outlined in 
> Effective C++
> and More Effective C++.
> 
> I personally would advocate using a C++ subset similar to "C with 
> classes".
> This could include virtual classes, because they're as efficient as 
> the
> alternative (function pointers).

That's more or less what's actually possible in the R5 kernel. Michael 
pointed me to a newsletter where is documented how you can use C++ in 
the BeOS kernel.

But for most drivers, you don't even need the "C with classes" model, 
since they are fundamentally I/O drivers.
Except for something like graphics drivers, where you could have an 
unaccelerated VESA driver as base class and all drivers can subclass 
this one driver to implement functionality, one function after another. 
Would be *very* convenient.
IIRC the BeOS graphics driver model achieves something similar with 
hooks.

Adios...
   Axel.



Other related posts: