Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!igor!rutabaga!jls From: jls@rutabaga.Rational.COM (Jim Showalter) Newsgroups: comp.object Subject: Re: Readability of Ada Message-ID: Date: 24 Apr 91 21:11:50 GMT References: <3878@ssc-bee.ssc-vax.UUCP> <20245@alice.att.com> <1991Apr23.193715.23815@odin.diku.dk> Sender: news@Rational.COM Lines: 55 ]>Now, I want to take a heterogeneous list of shapes, including triangles, ]>circles, and squares, and I want to iterate over the list and print ]>out all of the radii. ]Who wrote the heterogeneous-list code? The guy who supplied the shape ]classes? Of course not, because then he would have realized the need ]for a shape method to identify exactly what kind of shape it is. Uh huh. Precisely the point made in "Emperor Strikes Lethe"--you DON'T have any control over the guy who writes the class hierarchy upon which you depend. Indeed, in my example I specifically said that the class hierarchy is delivered in binary for security/monetary reasons, so you're at the mercy of it completely. And you just want to add a simple little class with some additional functionality--seems reasonable to me--but you CAN'T. ]That's why any C++ library programmer with just a little bit of sense ]adds such an operation. If the guy who wrote your binary collection ]of shape classes didn't do that, that's not a C++ problem No? Then why do OTHER inheritance-oriented languages provide self- identification of types automatically? ]No language, ]not even Ada can protect you against stupid programmers. Uh huh. All the more reason not to oversell the benefits of inheritance, considering you said earlier that building class hierarchies was very difficult. If it is really that difficult--and I argue it is--then Joe Blow is going to shoot his foot off. Giving the run-of-the-mill hacker the ability to screw up in increasingly subtle and grandiose ways does NOT strike me as a Great Leap Forward. ]C++ has a built-in type-discriminating mechanism called "dynamic ]binding". Yah, I know--my C++ compiler provides this. ]By the way, how about adding the tag method like this: ] ] typedef enum { CIRCLE_TAG, TRIANGLE_TAG, SQUARE_TAG } TAG; Okay, so now add a rectangle. You're back to editing the tag enumeration, and this is precisely how you'd do it in Ada. ]Still, this approach has it's problems, and I'm not claiming ]C++ to be superior to Ada. I am claiming, however, that ]dynamic binding is a valuable feature which Ada is missing. You're claiming it, but I don't think you've proven it. -- * "Beyond 100,000 lines of code, you should probably be coding in Ada." * * - P.G. Plauger, Convener and Secretary of the ANSI C Committee * * * * The opinions expressed herein are my own. *