Boost logo

Boost :

From: Maarten Kronenburg (M.Kronenburg_at_[hidden])
Date: 2006-11-29 07:54:15


"Tobias Schwinger" wrote in message
> Maarten Kronenburg wrote:
> > "As an unsigned, modular or allocated integer is an integer, these are
> > designed as (possibly template) classes derived from class integer with
> > virtual member functions and operators, providing runtime polymorphism.
Thus
> > a pointer of type integer * may point to an unsigned, a modular or an
> > allocated integer, which all behave like an integer (virtual methods)
but
> > with slightly different implementations.
>
> Pointer polymorphism is not important to have. If it really was, there
would be a polymorphic base for a sequences and strings in the standard
library.

As I mentioned before, it could be possible to add two strings with
different allocators (though it may be of low priority, lower than for
integers).

>
> > This may be compared with a driver,
> > which is an abstract class interface with only virtual functions.
>
> The unsigned integer inherits from the signed one. While this does model
arithmetics correctly (a natural number is an integer, after all), it is the
unsigned integer that has richer functionality. It's clumsy and not
extensible to use inheritance in such a case.

The normal and the unsigned integer have the same functionality, only the
implementation is slightly different.

>
> Allocation is orthogonal to all other properties, it applies to signed,
unsigned, and modular integers - so this part is even worse.
>
> > The
> > integer and a driver have in common that they are both very close to the
> > hardware.
>
> You said so already - and it doesn't make that lame excuse any better to
repeat it :-).
>
> > This is also the reason that for this basic type only basic
> > language elements are used, and not design patterns like singletons,
object
> > factories and smart pointers, which should be used at a higher
abstraction
> > level."
>
> Why do you think so? What are "basic language elements"? What is an
"object factory" (never heard of it)? Is there a design pattern called
"smart pointer" (yeah, there are smart pointers but these are not design
patterns, AFAIK)?

The book "Modern C++ Design, Generic Programming and Design Patterns
Applied" by Andrei Alexandrescu describes them in the same part as
"Components", but others may of course look at them differently.

>
> Really interesting that having a fancy name for "struct with static
function" makes it non-basic ;-)...
>
> > In an earlier discussion I have mentioned that there is a scale between
> > compile-time (static) polymorphism on the left to run-time (dynamic)
> > polymorphism on the right. Then the following items can be ordered from
left
> > to right:
> > containers strings integers drivers.
>
> No. Drivers are drivers. And strings and arbitrary precision integers are
containers with special operations.
> It might feel like writing a driver to you - but these are details
specific to your implementation that really should not have any impact on
the interface you choose!

Containers can be filled with any type (this is why they are templates), but
integers can only be filled with binary data in one single contiguous memory
block (see gmp). In my opinion this is very different.

>
> Let's continue this discussion once you are really interested in improving
the design.

Thanks for the discussion, it makes some things clear to me that I didn't
see before.
Regards, Maarten.

>
> Regards,
>
> Tobias
>


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