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-Thread: 103376,9eef6c480abeecf8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Dynamic array allocation and STL equivalents? References: <1108127216.221977.60830@o13g2000cwo.googlegroups.com> In-Reply-To: <1108127216.221977.60830@o13g2000cwo.googlegroups.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sat, 12 Feb 2005 01:04:21 GMT NNTP-Posting-Host: 63.186.32.51 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1108170261 63.186.32.51 (Fri, 11 Feb 2005 17:04:21 PST) NNTP-Posting-Date: Fri, 11 Feb 2005 17:04:21 PST Xref: g2news1.google.com comp.lang.ada:8266 Date: 2005-02-12T01:04:21+00:00 List-Id: brian.b.mcguinness@lmco.com wrote: > I would like to write a few Ada programs and play around with the > language a bit. From the mid 1980s through the early 1990s I wrote > programs in Borland Turbo Pascal 3 through 6, which I was quite fond > of, so I shouldn't have much trouble picking up Ada, which has a > similar syntax. But there are a few things I don't know how to do. > For one thing, I have looked through the Barnes book, the pages of > which have turned tan with age, and online, but can't find any > information on how to allocate arrays dynamically; there seems to be no > equivalent to the C malloc() function or the C++ dimensioned new. If > someone would tell me how to do this, I would appreciate it. Nobody addressed this, so I'll point out a simple way to create a dynamically sized array in Ada. I'll use the predefined array type String for simplicity: Dynamic_Array : declare S : String (1 .. N); begin -- Dynamic_Array -- Do something with S here end Dynamic_Array; N can come from the command line, input, a function, or anything else. There's no messing with pointers, no possibility of memory leaks or buffer overflows. -- Jeff Carter "If you think you got a nasty taunting this time, you ain't heard nothing yet!" Monty Python and the Holy Grail 23