comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: Dynamic array allocation and STL equivalents?
Date: Sat, 12 Feb 2005 01:04:21 GMT
Date: 2005-02-12T01:04:21+00:00	[thread overview]
Message-ID: <pCcPd.6266$mG6.382@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <1108127216.221977.60830@o13g2000cwo.googlegroups.com>

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



  parent reply	other threads:[~2005-02-12  1:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-11 13:06 Dynamic array allocation and STL equivalents? brian.b.mcguinness
2005-02-11 13:43 ` Jeff C
2005-02-14 15:23   ` Marc A. Criley
2005-02-11 14:41 ` Dmitry A. Kazakov
2005-02-11 15:50   ` Adrien Plisson
2005-02-11 17:47   ` REH
2005-02-12  9:28     ` Dmitry A. Kazakov
2005-02-12 18:52       ` Robert A Duff
2005-02-11 17:24 ` Bobby D. Bryant
2005-02-12  0:06   ` Robert A Duff
2005-02-12  3:45     ` Bobby D. Bryant
2005-02-11 18:07 ` Matthew Heaney
2005-02-11 18:36   ` Martin Krischik
2005-02-11 19:35 ` brian.b.mcguinness
2005-02-12  1:04 ` Jeffrey Carter [this message]
2005-02-12  6:19 ` Bobby D. Bryant
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox