[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: 0 or 0L for empty pointers?
From:       Lubos Lunak <l.lunak () suse ! cz>
Date:       2006-06-24 22:49:37
Message-ID: 200606250049.37990.l.lunak () suse ! cz
[Download RAW message or body]

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@suse.cz , l.lunak@kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic