0 or 0L for empty pointers?
Lubos Lunak
l.lunak at suse.cz
Sat Jun 24 23:49:37 BST 2006
On Friday 23 June 2006 18:15, Allan Sandfeld Jensen wrote:
> On Friday 23 June 2006 17:36, Lubos Lunak wrote:
> > Yet another own type system? Yes, you are oldfashioned.
>
> It's not another type system. It is just common sense.
>
> Look at KHTML for instance:
>
> Depending on tree, all object either derive from NodeImpl* or
> RenderObject*, and in many places you need to know what objects you are
> dealing with. When you _need_ a specific type of information you add it to
> your datatype. In this way type-information is no different from other
> types of information. This way you can have code that does:
>
> if (node->isTextnode())
> do the appropiate thing.
>
> Or as a side bonus you can do fast safe casts.
After you do the rtti yourself. This and the case below should not be really
different from using dynamic_cast in any respect beside the dlopen problem.
> if (node->isTextNode())
> static_cast<TextNodeImpl*>(node)->setText("Hello world!");
>
> Again: type-information is no different from any other type of information,
> if you need it, you add it your objects.
>
> `Allan
--
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o. e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27 tel: +420 2 9654 2373
190 00 Praha 9 fax: +420 2 9654 2374
Czech Republic http://www.suse.cz/
More information about the kde-core-devel
mailing list