Boost logo

Boost :

Subject: Re: [boost] 5 Observations - My experience with the boost libraries
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2010-03-23 22:57:25


On 03/23/2010 10:45 PM, Emil Dotchevski wrote:
> On Tue, Mar 23, 2010 at 6:56 PM, Stefan Seefeld<seefeld_at_[hidden]> 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...

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk