From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c04a86d57d8e19c4 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: C vs Ada code quality Date: 1997/04/26 Message-ID: #1/1 X-Deja-AN: 237504278 References: <336163A0.7B56@pratique.fr> Organization: New York University Newsgroups: comp.lang.ada Date: 1997-04-26T00:00:00+00:00 List-Id: <> First, I am not quite sure what you mean by *this*! You were replying to a thread which was specificaly discussing C and not C++. Second, I guess you must have a very limited view of the universe if you think it only contains Ada, C and C++ (do some investigation some time about what is atually used for development these days, the entries for COBOL, Delphi, Java, and especially Visual Basic may suprise you, not to mention the 4GL's. <> Right, you are not a specialist in Ada, and your guesses are wrong. I will say this again, quite clearly this time I hope: The controlled types in Ada are exactly equivalent to the destructors in C++. They involve dispatching only when it would also be neessary in C++. I don't know what leads to your misconceptions here, but they are misconceptions. Probably you are confusing the formal description with the implementation. The fact that controlled types in Ada are derived from controlled does not mean you have to implement them any differently from C++. <> Huh? Why should the use of the word vtable annoy me? I know perfectly well how typical implementations of of C++ use vtable pointers. You should look sometime at the implementation of GNAT/C++ interfacing which shows how vtable pointers are mapped into the GNAT/Ada 95 environment. HOWEVER, the ie here is very wrong (ie means "that is"). A vtable is not the dynamic type of the object. The latter is a formal semantic concept in the language. A vtable is one possible implementation approach. There is nothing in C++ that requires the use of the vtable approach, and there are other possibilities. <> yes,yes,yes you *are* comparing a particular implementation. You just don't realize what the distinction is between what is required in the semantics and what a typical implementation uses to provide these semantics. In both Ada and C++, finalization (destructors) are defined on individual types, and have to be called at the right time. End of story, no significant difference! Now you may wonder why in practice C++ implementations have avoided the use of dynamic lists for finalization, and Ada implementations have often used them. The answer is simple. Once you have to deal with exceptions the dynamic list has real advantages -- the C++ world is working through these problems now -- for example, see the discussions with respect to g++ and exeptions, where recently someone seriously suggested the possibility of going to lists for handling destructors. <> Of course not! You are forgetting separate compilation -- the same problem of course arises in C. Yes, you can sometimes tell for local variables (e.g. in the absence of subunits), but in C and C++ global variables have to be assumed to be aliased, and this is not the case in Ada.