home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!elroy.jpl.nasa.gov!swrinde!mips!mips!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Newsgroups: comp.lang.c++
- Subject: Re: Downcasting (was: Re: run-time type checking)
- Message-ID: <1992Aug15.000101.8975@ucc.su.OZ.AU>
- Date: 15 Aug 92 00:01:01 GMT
- References: <9222518.29381@mulga.cs.mu.OZ.AU> <4820@holden.lulea.trab.se> <9222715.29197@mulga.cs.mu.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- Lines: 44
- Nntp-Posting-Host: extro.ucc.su.oz.au
-
- In article <9222715.29197@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- >jbn@lulea.trab.se (Johan Bengtsson) writes:
- >
- >>maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >>:
- >>:There are other ways than tagged pointers to make downcasting
- >>:sound. One might be to declare the derived classes that you want
- >
- >If I pass you a Base*, I expect that you will only be able to modify it
- >using the Base interface. Thus if you want to be able to modify it using
- >the Derived interface, then the conversion from Base* to Derived* should
- >be an explicit part of the Base interface.
- >
- >The real drawback is the amount of typing required. This can be reduced
- >with macros if desired.
- >
-
- Or with tagged pointers. They're meant to optimise the
- typing down to the amount needed and no more, excepting for
- the interface declarations.
-
- [A,B,C]*p;
- p->print();
-
- Calls A::print(), B::print(), C::print() depending. Even less
- typing than for the downcasting proposal. Indeed, one of the
- criticisms of tagged pointers is that REAMS AND REAMS of code
- can be generated by the compiler from a few simple uses.
-
- [A,B,C,D,E] *a, *b, *c;
-
- f(a,b,c);
-
- Generates switches to call up to 625 different cases. If f
- is a template function, all 625 cases of the function will be
- created as well!
-
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-