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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6b6181765c24743 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-02-05 16:36:44 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!news-out.usenetserver.com!news-out.usenetserver.com!newsfeed.direct.ca!look.ca!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3A7F4719.572545D5@acm.org> From: Jeffrey Carter X-Mailer: Mozilla 4.7 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Generics - Difference between ADA and Modula--3 References: <3a7646fb$1@rsl2.rslnet.net> <956ols$qtv$1@news.cis.ohio-state.edu> <95eumd$8i41@news.cis.okstate.edu> <95n3oi$5nh$1@news.cis.ohio-state.edu> <95n705$9ic1@news.cis.okstate.edu> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 06 Feb 2001 00:36:43 GMT NNTP-Posting-Host: 158.252.123.46 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 981419803 158.252.123.46 (Mon, 05 Feb 2001 16:36:43 PST) NNTP-Posting-Date: Mon, 05 Feb 2001 16:36:43 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: supernews.google.com comp.lang.ada:4955 Date: 2001-02-06T00:36:43+00:00 List-Id: David Starner wrote: > > for I in 1 .. 50 loop > declare > A: array (0 .. I) of Integer; > begin > ... > end; > end loop; > > where there's a varying array. Or alternately: > > type bob is array (integer range <>) of foo; > ... > while (complex_condition) loop > declare > Token: bob := Something_Returning_A_Varying_String; > begin > ... > end; > end loop; A very common version of this is declare S : String := PragmARC.Get_Line; begin ... (Shameless plug: see the PragmAda Reusable Components at http://home.earthlink.net/~jrcarter010/pragmarc.htm ). S may be from zero to Positive'Last characters long. In Ada, you only really need explicit memory allocation and deallocation for things like unbounded dynamic data structures, such as linked lists. In C you need them whenever the size of something is not known at compile time. It should also be noted that controlled types can be used for automatic deallocation of explicitly allocated memory, getting much of the advantage of garbage collection with the predictable run times of manual memory management. -- Jeff Carter "Go and boil your bottoms." Monty Python & the Holy Grail