home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!uwm.edu!ogicse!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: "type safety" deemed essential
- Message-ID: <TMB.93Jan6220042@arolla.idiap.ch>
- Date: 7 Jan 93 06:00:42 GMT
- Article-I.D.: arolla.TMB.93Jan6220042
- References: <450@genie.UUCP> <725053473snx@trmphrst.demon.co.uk>
- <726346306snx@trmphrst.demon.co.uk>
- Reply-To: tmb@idiap.ch
- Distribution: world
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 22
- NNTP-Posting-Host: arolla.idiap.ch
- In-reply-to: nikki@trmphrst.demon.co.uk's message of Wed, 6 Jan 1993 11:51:46 +0000
-
- In article <448@genie.UUCP> roger@genie.UUCP (Roger H. Scott) writes:
- > ... [W]ho has written a non-trivial commercial C++
- > application *without* making significant use of either type casting [(T *)]
- > or run-time type checking [Bar *bar_p = foo_p->asBar();]?
-
- In article <726346306snx@trmphrst.demon.co.uk> nikki@trmphrst.demon.co.uk (Nikki Locke) writes:
- > [suggesting that some 31000 lines of code he has written without
- > using these features are "non-trivial"]
-
- Unfortunately, C++ still lacks some kind of "tagged union type",
- "typesafe union type", or, if you are a Pascal fan, a "variant record
- with runtime type checking". Those kinds of datatypes are useful in
- many applications. A common example is that of a binary tree with
- different node and leaf types.
-
- There are workarounds, but they either use a lot more memory (using a
- "struct" instead of a "union"), or they aren't type-safe (pointer
- casts or C-style unions). And with any such workaround in C/C++, you
- are missing out on useful compile time diagnostics and optimizations
- that would be possible if the feature was supported.
-
- Thomas.
-