Re: Ada.Command_Line and wildcards
- From: Georg Bauhaus <bauhaus@xxxxxxxxxxxxx>
- Date: Tue, 27 Feb 2007 17:13:13 +0100
On Mon, 2007-02-26 at 18:34 +0100, Markus E Leypold wrote:
"Hyman Rosen" <hyman.rosen@xxxxxxxxx> writes:
On Feb 26, 3:44 am, "Dmitry A. Kazakov" <mail...@xxxxxxxxxxxxxxxxx>
wrote:
Further, why do you presume that heap is larger than stack?
AFAIK, nothing in RM requires or implies that.
Past experience. If that's not the case for some implementation then
fine, but I suspect it's more often the case then not. I'm pretty sure
we've seen newbie examples on the newsgroup where they create
unconstrained objects (is that the right term?) on the stack and then
wonder why their program doesn't work.
I'm also pretty sure that in most of those cases creating them on the
heap wouldn't work either.
IIRC, two non-GNAT Ada compilers had no trouble whatsoever
allocating objects of type array (1 .. N) of Something,
N <= available_heap_memory, independent of the OS stack size.
Also, I think Hyman remembers correctly: rewriting Ada programs
to use explicit heap allocation for dynamically sized arrays
can make GNAT-translated Ada programs work.
I understand that Janus/Ada allocates on the heap, too,
so there shouldn't be a problem either for any N below
available heap memory.
Really, isn't this an issue of how to best use GNAT
for Ada programs when they have potentially large objects.
GNAT:
$ ./big
Enter size: 50_000_000
size is 50000000
raised STORAGE_ERROR : big.ada:6 object too large
$
AppletMagic:
$ java big
Enter size: 50_000_000
size is 50000000
Enter Q: q
$
For the same quick and dirty program,
with Ada.Text_IO;
procedure big is
procedure make(n: NATURAL) is
local: array(1 .. n) of Character;
begin
if local'length > 0
then local(local'last) := local(local'length / 2);
end if;
end make;
buffer: String(1 .. 20);
last: Natural; -- dual use
begin
Ada.Text_IO.put("Enter size: ");
Ada.Text_IO.Get_line(buffer, last);
last := Integer'value(buffer(1 .. last));
Ada.Text_IO.put_line("size is" & Integer'image(last));
make(last);
Ada.Text_IO.put("Enter Q: ");
Ada.Text_IO.Get_Line(buffer, last);
end;
Especially if the unconstrained parameter
was determining an array size and was of type Natural or Positive.
Regards -- Markus
.
- Follow-Ups:
- Re: Ada.Command_Line and wildcards
- From: Randy Brukardt
- Re: Ada.Command_Line and wildcards
- From: Markus E Leypold
- Re: Ada.Command_Line and wildcards
- References:
- Ada.Command_Line and wildcards
- From: Gautier
- Re: Ada.Command_Line and wildcards
- From: (see below)
- Re: Ada.Command_Line and wildcards
- From: gautier_niouzes
- Re: Ada.Command_Line and wildcards
- From: Jean-Pierre Rosen
- Re: Ada.Command_Line and wildcards
- From: Robert A Duff
- Re: Ada.Command_Line and wildcards
- From: Larry Kilgallen
- Re: Ada.Command_Line and wildcards
- From: Robert A Duff
- Re: Ada.Command_Line and wildcards
- From: Hyman Rosen
- Re: Ada.Command_Line and wildcards
- From: Robert A Duff
- Re: Ada.Command_Line and wildcards
- From: Pascal Obry
- Re: Ada.Command_Line and wildcards
- From: Dmitry A. Kazakov
- Re: Ada.Command_Line and wildcards
- From: Hyman Rosen
- Re: Ada.Command_Line and wildcards
- From: Dmitry A. Kazakov
- Re: Ada.Command_Line and wildcards
- From: Hyman Rosen
- Re: Ada.Command_Line and wildcards
- From: Markus E Leypold
- Ada.Command_Line and wildcards
- Prev by Date: Re: Preferred OS, processor family for running embedded Ada?
- Next by Date: Re: Ada.Command_Line and wildcards
- Previous by thread: Re: Ada.Command_Line and wildcards
- Next by thread: Re: Ada.Command_Line and wildcards
- Index(es):
Relevant Pages
|