Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Misuses of ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 34 Topic 9585 of 10104
Post > Topic >>

Re: Misuses of RTTI

by Tony Delroy <tony_in_da_uk@[EMAIL PROTECTED] > May 14, 2008 at 08:38 AM

On May 14, 12:12 pm, galathaea <galath...@[EMAIL PROTECTED]
> wrote:
> On May 10, 5:14 am, Francis Glassborow
> <francis.glassbo...@[EMAIL PROTECTED]
> wrote:
> > [RTTI] was introduced along with
> > dynamic_cast in response to the fact that developers (skilled ones) of
a
> > good number of libraries were synthesising the functionality of RTTI
> > manually...
>
> and it failed horribly to provide what was needed
>
> what was needed was enough introspection to automate serialisation
> i.e.
>    - a way to automatically get an identifier for an object
>      that _uniquely_ identified it's type across runtimes
>    - a means of enumerating
>        and iterating
>      over the member variables and up the inheritance hierarchy
>
> basically the structure needed to fill a factory
>    and prevent duplication of effort
>    (and possible divergence errors)
>
> neither of these objectives were fulfilled
>
> there is never a reason for dynamic_cast in properly architected code
> (though dealing with libraries with poor architecture
>   sometimes makes it necessary)
>
> i'm still not positive any of this will be possible in c++0X
>
> it's really quite sad
> since serialisation frameworks are error prone without it
>    and usually require code generation to make up for c++'s lacks

I don't buy this.  C++ does have a terrible lack of introspective
ability, no argument.  But RTTI/dynamic_cast<> is useful for other
unrelated uses.  Introspection may have been what you wanted, and you
may have looked to RTTI to provide it, but you can't blame these
features for C++'s lack of introspection just because they're the
closest thing to what you want.  templates - due to various side-
effects of rules about their use - provide half-baked introspective
capabilities too, but similarly have their separate merits.

For example, I deal with a tree of GUI gadgets.  I have a registry
from identifiers to the gadget base class.  If a scripted statement
asks for an behavioural attribute to be changed, I can dynamic_cast<>
from the base class to the derived class that embodies that attribute,
and perform the appropriate action or query.  I have no desire to
pollute the base class with a fat interface aggregating all the tree's
attributes.  So, tell me what's wrong with this model...?

Tony

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 34 Posts in Topic:
Misuses of RTTI
OuFeRRaT <ouferrat@[EM  2008-05-09 21:13:35 
Re: Misuses of RTTI
Pavel Minaev <int19h@[  2008-05-10 05:52:08 
Re: Misuses of RTTI
Mathias Gaunard <loufo  2008-05-10 05:53:41 
Re: Misuses of RTTI
brangdon@[EMAIL PROTECTED  2008-05-10 06:14:41 
Re: Misuses of RTTI
Francis Glassborow <fr  2008-05-10 06:14:40 
Re: Misuses of RTTI
MiB <Michael.Boehnisch  2008-05-10 14:08:42 
Re: Misuses of RTTI
"Bo Persson" &l  2008-05-11 16:40:58 
Re: Misuses of RTTI
Carl Barron <cbarron41  2008-05-11 22:13:29 
Re: Misuses of RTTI
=?UTF-8?B?RXJpayBXaWtzdHL  2008-05-13 10:55:29 
Re: Misuses of RTTI
galathaea <galathaea@[  2008-05-13 21:12:13 
Re: Misuses of RTTI
Gerhard Fiedler <gelis  2008-05-13 21:27:28 
Re: Misuses of RTTI
bravo <szymon.gatner@[  2008-05-14 08:36:57 
Re: Misuses of RTTI
brangdon@[EMAIL PROTECTED  2008-05-17 02:27:45 
Re: Misuses of RTTI
Tony Delroy <tony_in_d  2008-05-14 08:38:14 
Re: Misuses of RTTI
Mathias Gaunard <loufo  2008-05-14 12:27:28 
Re: Misuses of RTTI
Mathias Gaunard <loufo  2008-05-14 12:55:43 
Re: Misuses of RTTI
anthonypon@[EMAIL PROTECT  2008-05-15 02:47:07 
Re: Misuses of RTTI
Greg Herlihy <greghe@[  2008-05-15 11:21:05 
Re: Misuses of RTTI
dizzy <dizzy@[EMAIL PR  2008-05-15 11:57:29 
Re: Misuses of RTTI
dizzy <dizzy@[EMAIL PR  2008-05-15 11:57:29 
Re: Misuses of RTTI
Edward Diener <diener8  2008-05-15 15:57:15 
Re: Misuses of RTTI
Mathias Gaunard <loufo  2008-05-16 17:30:34 
Re: Misuses of RTTI
Frank Birbacher <blood  2008-05-16 17:44:13 
Re: Misuses of RTTI
Daniel James <wastebas  2008-05-16 17:43:20 
Re: Misuses of RTTI
"Marcin Kalicinski&q  2008-05-17 02:57:29 
Re: Misuses of RTTI
Edward Diener <diener8  2008-05-17 14:38:55 
Re: Misuses of RTTI
Greg Herlihy <greghe@[  2008-05-17 14:36:47 
Re: Misuses of RTTI
Edward Diener <diener8  2008-05-17 14:39:16 
Re: Misuses of RTTI
Andre Kaufmann <akfmne  2008-05-17 14:38:10 
Re: Misuses of RTTI
Andre Kaufmann <akfmne  2008-05-17 23:20:59 
Re: Misuses of RTTI
Daniel James <wastebas  2008-05-18 16:48:55 
Re: Misuses of RTTI
Andre Kaufmann <akfmne  2008-05-19 06:05:40 
Re: Misuses of RTTI
Francis Glassborow <fr  2008-05-19 12:01:47 
Re: Misuses of RTTI
Francis Glassborow <fr  2008-05-20 18:59:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Oct 15 22:33:39 CDT 2008.