Newsgroups: comp.lang.c++ Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!pdn!tscs!tct!chip From: chip@tct.com (Chip Salzenberg) Subject: Re: Casting downward Message-ID: <284B857B.4D61@tct.com> Date: Tue, 04 Jun 1991 12:20:11 GMT References: <675518012.11@sunbrk.FidoNet> <28468F0F.4444@tct.com> <2352@media03.UUCP> Organization: Teltronics/TCT, Sarasota, FL According to pkr@media03.UUCP (Peter Kriens): >Chip Salzberg writes: >> I take care in my C++ programming not to lose the static type of any >> object for which I will need that static type later on. Obviously, >> this means that I cannot use just one Array class, one Bag class, etc. >> >> It's better to be type-safe than to be convenient. > >Is there any research done validates this statement? Not as far as I know. My personal experience and my understanding of the strengths and weaknesses of C++ led me to that conclusion. >In the C++ language being typesafe means code duplication and handling >a lot more cases. Not really. The preprocessor is a wonderful thing, and templates are even better. I cannot create just one Array class, for example; but with the preprocessor, I can automatically generate StringArray, IntArray, etc. without any additional coding. And templates bring the effort required to create specialized classes down to almost zero. >So which one wins,lesser code ( is I assume lesser bugs) and >more reuse, or the type safety? Reuse is not much of an issue, thanks to the preprocessor and templates. Therefore, for me, the only remaining issue is bugs. And I'd prefer to catch typing bugs at compile time instead of letting them lie in wait to bite me at run time. "Never put off until run time that which can be done at compile time." -- Chip Salzenberg at Teltronics/TCT , perl -e 'sub do { print "extinct!\n"; } do do()'