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,897417b380f5731e X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: STL, Ada, C++ (Was Re: The Next Microsoft?) Date: 2000/05/09 Message-ID: #1/1 X-Deja-AN: 621153370 References: <8eu0ob$7qv$1@nnrp1.deja.com> <391328F0.1221@synquiry.com> <39133213.64A@Ganymede.com> <8f50hc$hpo$1@nnrp1.deja.com> <8f83i2$osk$1@slb1.atl.mindspring.net> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 957886266 203 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-05-09T00:00:00+00:00 List-Id: On Tue, 9 May 2000, Richard D Riehle wrote: > In article , > Hyman Rosen wrote: > >Robert Dewar writes: > >> I am not at all convinced that automatic instantiation is > >> a help to the reader and maintainer, on the contrary, it > >> seems very awkward to have uses of templates not be visible > >> from this point of view. > > > >I consider automatic instantiation of templates to be the compile-time > >polymorphism equivalent of run-time dispatching on class-wide types. > >When you make a dispatching call, you do not know what function you > >are calling. Similarly, you should be able to call a generic function > >without explicitly stating which one you are calling. > > I wonder if there is a trade-off here between convenience and type > safety. Ada tends to lean heavily in the direction of safety, > and automatic instantiation seems not quite as focused on that issue. Overloading, runtime dispatching, and "use clauses" don't seem quite as focused on safety either. The only way that automatic instantiation is troubling is that in the case of a language like C++ it is undecidable, I think in standard C++ they limit the depth of template expansion (Hyman?) and I imagine a similar solution would be needed for Ada. > For example, the model for generic formal package parameters in Ada > forces the designer to create a generic signature package corresponding to > the parameter. This makes automatic instantiation quite difficult to > achieve, but has the benefit of pretty thorough compile-time evaluation > of all the elements of the signature. Here are the rules for automatic instantiation proposed by Shen and Cormack: -- (1) Allow the name of a generic subprogram to appear wherever a -- non-generic subprogram name is now allowed. -- -- (2) Allow non-generic subprograms to overload generics -- -- (3) Allow a subprogram component of a generic package to appear where -- non-generic subprogram name is allowed. -- -- (4) Allow generic package name to be specified in a "use" clause, thus -- allowing subprogram components to be specified without -- qualification according to rule (3) -- -- (5) Allow some or all real parameters to be omitted in an explicit -- instantiation Packages in package parameters would not be inferred. > The goals of C++ are different from those of Ada. If a programmer feels > more comfortable with C++ goals, then C++ is a good choice. If someone > feels better with the goals of Ada, then Ada should be the choice. Programming languages don't have goals, people do. Languages are artifacts that can and should be discussed dispassionately. If a programmer believes that a major feature of another language can be adapted to his preferred language, why shouldn't he wish for change? > Also, > those goals are intended to satisfy different levels of confidence in the > final product. Would anyone who knows C++ well feel comfortable knowing the > software for the avionics on their aircraft was programmed in C++? > Most of those I ask, say, "No way." Ada is targeted to exactly that > kind of application environment. Scaling back a bit from that extreme, > Ada still inspires a greater sense of confidence in its goals than C++ > when safety is an issue. "C++ is deficient with respect to Ada in the safety critical realm" "C++ has automatic instantiation" "Therefore automatic instantiation is deficient ..." > Automatic instantiation does not inspire confidence, but that > may not matter if a software failure does not kill or maim anyone. Your emotional rhetoric is unconvincing. Any language with type inference has a kind of automatic instantiation and "lack of safety" is not a reasonable negative claim to make. -- Brian