home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!igor!thor!rmartin
- From: rmartin@thor.Rational.COM (Bob Martin)
- Newsgroups: comp.lang.c++
- Subject: Re: Language extensions for run-time type identification
- Message-ID: <rmartin.711827497@thor>
- Date: 22 Jul 92 17:51:37 GMT
- References: <EY048MK@netmbx.netmbx.de> <TMB.92Jul20182052@arolla.idiap.ch>
- Sender: news@Rational.COM
- Lines: 39
-
- tmb@arolla.idiap.ch (Thomas M. Breuel) writes:
-
- >As I understand it (I haven't read the proposal), there will
- >apparently be a half-hearted attempt at adding runtime type tags to
- >some user-defined classes. From the descriptions of the proposal that
- >I have heard, that will not be sufficient to make the C++ language
- >safe (in the sense of eliminating most sources of "undefined
- >behavior"). In fact, at best, it will encourage a careless programming
- >style that relies on runtime type tests rather than inheritance and
- >virtual functions.
-
- Ack! Such cynisism; and from someone who hasn't even read the
- proposal yet! First read the proposal, *then* you can be cynical.
-
- Actually, the RTTI proposal sounds pretty good to me. (I have read
- it.) It is a trade-off, as is nearly every feature of C++; but it is
- a well thought out one. It certainly makes the language safer, since
- casts which had been legal and unchecked will now become dynamically
- checked. Will it encourage careless programming? Please! Careless
- programing is perpetrated by careless programmers. Careless
- programmers are not thwarted in their intentions by the language they
- use.
-
- Can RTTI be misused? Certainly! So can integers:
- for (i=0; i<1e99; i++) ;
-
- Does RTTI improve the language? Yes, emphatically. Specifically in
- the area of identifying objects which come out of heterogenous
- containers. Some have expressed the opinion that RTTI should not be
- used in this way since the objects in heterogenous containers should
- be accessed only by their known interface. This is usually correct.
- But there are occasions where DOWNCASTING such objects is useful.
-
-
- --
- +---Robert C. Martin---+-RRR---CCC-M-----M-| R.C.M. Consulting |
- | rmartin@rational.com |-R--R-C----M-M-M-M-| C++/C/Unix Engineering |
- | (Uncle Bob.) |-RRR--C----M--M--M-| OOA/OOD/OOP Training |
- +----------------------+-R--R--CCC-M-----M-| Product Design & Devel. |
-