home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:11839 comp.std.c++:1002
- Newsgroups: comp.lang.c++,comp.std.c++
- Path: sparky!uunet!sun-barr!cs.utexas.edu!convex!constellation!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Language extensions for run-time type identification
- Message-ID: <1992Jul30.163821.17353@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Jul26.014223.6153@uunet.uu.net!mole-end> <1992Jul27.173614.8320@cadsun.corp.mot.com> <1992Jul28.094428.15393@uunet.uu.net!mole-end>
- Date: Thu, 30 Jul 1992 16:38:21 GMT
- Lines: 50
-
- In article <1992Jul28.094428.15393@uunet.uu.net!mole-end> mat@uunet.uu.net!mole-end writes:
- >
- >> > Only derivation can make use of RTTI.
- >
- >> I disagree. Derivation needs RTTI does not mean that only derivation needs
- >> RTTI. Parameterization needs RTTI too (of cause, it is not the C++ template).
- >
- >RTTI is only needed when an object can have an apparent type and an actual
- >type. In C++, that requires derivation.
-
- Not so. RTTI could easily be useful for distinguishing between
- unrelated types.
-
- In fact, these type *might* have a base in common, but the
- is not relevant.
-
- Consider the syntax
-
- f(X[Y,Z]*);
-
- which is taken to mean a pointer to X, with downcasting to Y and Z
- allowed. If we allow,
-
- f([Y,Z]*);
-
- then it is much the same, except that there is no 'default' type,
- and the argument cannot be used directly.
-
- One can easily see how this can be used to implement a Lisp system:
-
- typdef [float,int,string] atom;
-
- class node {
- node *CAR;
- [node, atom]* CDR;
- };
-
- The notion is equivalent to a pascal variant record with run-time
- checking on the discriminant.
-
- In the case above, tagged pointers may have to be used.
-
- When there is a common base with a virtual member, RTTI in the object
- can be used instead. But that is an compiler implementation detail.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-