comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Generics - Difference between ADA and Modula--3
Date: Tue, 06 Feb 2001 00:36:43 GMT
Date: 2001-02-06T00:36:43+00:00	[thread overview]
Message-ID: <3A7F4719.572545D5@acm.org> (raw)
In-Reply-To: 95n705$9ic1@news.cis.okstate.edu

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



  reply	other threads:[~2001-02-06  0:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-30  4:48 Generics - Difference between ADA and Modula--3 John Baltomoire
2001-01-30 16:04 ` Mark Carroll
2001-02-02 18:35   ` David Starner
2001-02-05 20:51     ` Mark Carroll
2001-02-05 21:46       ` David Starner
2001-02-06  0:36         ` Jeffrey Carter [this message]
2001-02-05 22:46       ` Pat Rogers
     [not found]       ` <95p1p7$3s9$1@nnrp1.deja.com>
     [not found]         ` <slrn98049v.155.lutz@taranis.iks-jena.de>
2001-02-07 13:10           ` John English
2001-02-12 20:38       ` Mark Carroll
2001-02-05 23:12     ` Mark Lundquist
2001-02-05 23:50       ` David Starner
2001-02-06  0:03       ` David Starner
     [not found] <mailman.981529807.716.comp.lang.ada@ada.eu.org>
2001-02-07 14:52 ` Ted Dennison
replies disabled

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