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.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLYTO_END_DIGIT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,198c6302c4a0b0d7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-19 12:30:14 PST From: Patrick Hohmeyer Subject: Re: was Re: Ada / C++ comparison paper anymore Newsgroups: comp.lang.ada Reply-To: pi3_1415926536@yahoo.ca References: <3c1dc786@pull.gecm.com> <1008601517.470745@edh3> <1008626816.690418@master.nyc.kbcfp.com> <1008690461.380980@master.nyc.kbcfp.com> <_xRT7.4398$xl6.682759@rwcrnsc54> <_T4U7.8960$xl6.990924@rwcrnsc54> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8Bit User-Agent: KNode/0.3.2 Message-ID: Date: Wed, 19 Dec 2001 15:51:43 -0500 NNTP-Posting-Host: 65.94.190.113 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1008793635 65.94.190.113 (Wed, 19 Dec 2001 15:27:15 EST) NNTP-Posting-Date: Wed, 19 Dec 2001 15:27:15 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:18118 Date: 2001-12-19T15:51:43-05:00 List-Id: Mark Lundquist wrote : > No, but if I want to write > > procedure P2 is new P_Base (T2); > > I can certainly do that, right? And while P1 is primitive to T1 and P2 is > not necessarily primitive to T2 (depending on the scope of the > instantiation), an implicit instantiation is obviously not primitive > either. > I'm not seeing how my scheme weakens anything at all... It just results > in > a lighter syntax. Can you please be more specific about *exactly* what > problems you see it causing, and how? I would be genuinely interested to > know... > Ok, an exemple : procedure X is generic type Number is range <>; type Num_Arr is array (Integer range <>) of Number; function Mean(A : Num_Arr) return Number; function Mean(A : Num_Arr) return Number is Sum : Integer := 0; begin for I in A'Range loop Sum := Sum + Integer(A(I)); end loop; return Number(Sum/A'Length); end Mean; type T_Employes is array(Integer range <>) of Natural; -- employe numbers type T_Employe_S is array(Integer range <>) of Natural; -- employe salaries function Sal_Mean is new Mean(Natural,T_Employe_S); Employes : T_Employes(1..1000); Employe_S : T_Employe_S(1..1000); Mean_Sal : Natural; begin Mean_Sal := Sal_Mean(Employe_S); -- line 1 Mean_Sal := Sal_Mean(Employes); -- line 2 end X; --end code ----------------------- First, I know that identifiers as similiar as Employes and Employe_S are bad. You can easly mix them and thats exactly the point here. Line 1 is correct, we calculate the mean salary of our employes. But Line 2 calculates the mean of the employe numbers. This makes no sense, and thanks to Ada this dont even compile, as I haven't defined the Mean function for the employe numbers. But with your auto-instanciation, I simply would write Mean and nobody catched the error. It compiles and even *runs* fine, only the results are completly nonsense. That's why I'm against auto-instantiations. People make bugs. And everything that is transformed auto-magicly helps bugs to survive longer. -- Patrick Hohmeyer