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=-0.3 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,982ed90dd25179ec X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-06 17:35:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Reply-To: "James S. Rogers" From: "James S. Rogers" Newsgroups: comp.lang.ada References: <1041186672.615164@ns2-ext.dcu.ie> <8EIP9.19113$p_6.1493222@bgtnsc04-news.ops.worldnet.att.net> <24oS9.30853$p_6.2594702@bgtnsc04-news.ops.worldnet.att.net> Subject: Re: point by point advantages of Ada X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Message-ID: Date: Tue, 07 Jan 2003 01:35:26 GMT NNTP-Posting-Host: 12.86.37.123 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1041903326 12.86.37.123 (Tue, 07 Jan 2003 01:35:26 GMT) NNTP-Posting-Date: Tue, 07 Jan 2003 01:35:26 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:32652 Date: 2003-01-07T01:35:26+00:00 List-Id: "David Thompson" wrote in message news:24oS9.30853$p_6.2594702@bgtnsc04-news.ops.worldnet.att.net... > James S. Rogers wrote : > ... > > The solution for such a need is basically the same in both C++ and Ada. > > C++ provides no multiple dispatch capability. You must make such a > > function static, not virtual. In Ada you do the same thing. You simply > > define the procedure(s) taking more than one tagged type in another > > scope. An inner package is a common choice for another scope. > > > static is not the opposite of virtual, see below. In C++ you can allow > the normal, implicit dispatch on one type (virtual) and do the other(s) > explicitly; or have a nonvirtual function that does both/all. Yes in Ada > the options are effectively the same. Another difference in C++ is that a static function does not contain an implicit "this" variable. This means that static function calls resemble Ada subprogram calls in the fact that all the parameters must be passed between the parentheses. > > ... > > What the original author does not mention is that C++ cannot dispatch > > based upon the return type of a function. This is done cleanly in Ada and > > not at all in C++ (or Java). > > > Ada uses return type to resolve overloading (at compile time), but > not to dispatch (possibly at run time). (C++ and Java do neither.) Quoting from "Ada as a Second Language" by Cohen: "If a primitive function of a type T has a result of type T, but no parameters of type T or access T, a call on the function can be either nondispatching or dispatching depending on the context." This is clearly more than simple overload resolution. > > > In C++ you need to explicitly label a function as "virtual". The default is > > "static". In Java the default is the equivalent of virtual, and you must > > explicitly label "static" functions with the "static" keyword. In Ada > > functions are primitive to a type if they are declared in the same scope > > as the declaration of the type. That is, the "primitive" property is defined > > by scope, and not by the presence or absence of a reserved word. > > This is different from C++ and Java, but those languages also differ > > from each other. Such differences do not prove superiority. > > > C++ virtual and Java *final* are opposites, and yes the default is I stand corrected about the relationship between static and virtual. Thank you for the correction. > reversed, but *static* (in both) is quite different -- it specifies methods > or variables which are per-class not per-instance. (As well as having > other meanings in C++, and C, for things not in a class.) Static data is similar to data items defined in a package body or specification in Ada. Yes, C++ has provided a marvelous set of overloadings for the reserved word "static", just as Ada has for the reserved word "new". Jim Rogers