
On 03/23/2010 10:45 PM, Emil Dotchevski wrote:
On Tue, Mar 23, 2010 at 6:56 PM, Stefan Seefeld<seefeld@sympatico.ca> wrote:
On 03/23/2010 09:47 PM, Emil Dotchevski wrote:
In many cases, I'd rather design a C-style interface that takes pointers to incomplete types or even void pointers. Then *maybe* if it makes sense I would use meta-programming tricks in the implementation.
I wonder how that goes together. Once you start using "pointers to incomplete types" etc., you have given up valuable (type) information
...and I have not paid the price for that information: physical coupling!
I agree. But that's now a completely separate concern. Remember we are arguing about performance and how it is impacted by the choice of language and API.
which you can not gain back "in the implementation". So what meta-programming tricks are there left to play ?
Pointers to incomplete types are type-safe but yes, in general, I'm talking about balancing compile-time type safety and physical coupling.
The "proper" way to do this in C++ is to use abstract base classes;
Sorry, no. An "abstract base class" is something specifically tied to the Object Oriented Programming paradigm, and thus, runtime binding. Meta-programming, on the other hand, is all about compile-time binding, which you can't get with abstract base classes.
except that an interface defined in terms of C-style functions is more abstract than a C++ abstract base class because calling a C-style function doesn't necessarily result in a virtual function call (yet it *can* call a virtual function internally, if that makes sense.)
You are comparing apples and oranges. If you want the kind of abstraction that abstract base classes give you, i.e. (runtime) polymorphism, you surely want to operate with some form of function pointers. And these are very similar to virtual functions. I can't believe we are having this discussion on this list... Stefan -- ...ich hab' noch einen Koffer in Berlin...