POV-Ray : Newsgroups : povray.general : CSDL: C-like Simulation Description Language : Re: CSDL alpha 1 release Server Time
7 Aug 2024 07:18:19 EDT (-0400)
  Re: CSDL alpha 1 release  
From: Thorsten Froehlich
Date: 23 Jan 2002 19:45:35
Message: <3c4f592f$1@news.povray.org>
In article <3c4f5132@news.povray.org> , Warp <war### [at] tagpovrayorg>  wrote:

>   I have used multiple inheritance. I haven't needed dynamic_cast<> (nor
> any other cast for that matter).
>
>   dynamic_cast<> is one of those casts which you just shouldn't use (ok,
> not that; what I mean is that you should almost never use downcasting;
> downcasting is generally bad).
>   The other casts you should never use are const_cast<> (used just as a hack
> for dealing with old bad-designed libraries) and reinterpret_cast<> (which
> is mainly used for low-level hacking).

Not sure if you can access it, but if you have access to the
/povray/tools/povdocgen/ directory in Perforce, could you explain to me how
to design classes so that they can contain and access an HTML (or XML to be
more general) parse tree - or (almost) any parse tree for that matter -
without having to use casting?

Or, to be more precise, you have two kinds of classes that have nothing in
common expect that they can be turned into text and back (thus those
functions are in the common base class).

However, one class only stores plain text while the other class has
attributes and stores no plain text at all. Yet objects can be nested inside
the class with attributes, which needs to store a list with any number of
objects of either class.

So one either uses casting or one class which contains a list and a string
and only uses either.  The first way is the proper design, the second is the
worst possible design.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.