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,aeab6b16387b2612 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-07-15 22:31:13 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!feed2.news.rcn.net!rcn!newsfeed1.earthlink.net!newsfeed.earthlink.net!newsmaster1.prod.itd.earthlink.net!newsread2.prod.itd.earthlink.net.POSTED!not-for-mail Message-ID: <3B527C15.2B0E5BCC@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: How to do it in Ada ? References: <9itna2$i5b$1@news.tpi.pl> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 16 Jul 2001 05:31:21 GMT NNTP-Posting-Host: 158.252.128.180 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 995261481 158.252.128.180 (Sun, 15 Jul 2001 22:31:21 PDT) NNTP-Posting-Date: Sun, 15 Jul 2001 22:31:21 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net X-Received-Date: Sun, 15 Jul 2001 22:28:45 PDT (newsmaster1.prod.itd.earthlink.net) Xref: archiver1.google.com comp.lang.ada:9983 Date: 2001-07-16T05:31:21+00:00 List-Id: Tomasz Wegrzanowski wrote: > > int main(int argc, char **argv) > { > int *x; > int n; > > n = (argc==1)?1:atoi(argv[1]); > x = malloc (n*sizeof(int)); > for (x=0;x x[i]=0; > > /* ... */ > } > > Something like that ... how to do such dynamic array allocation in Ada ? The simple answer is, you don't. Ada makes this kind of thing much simpler and less error-prone than in a low-level language. procedure The_Right_Way is type List is array (Positive range <>) of Integer; function Get return Positive is separate; Num_Integers : constant Positive := Get; X : List (1 .. Num_Integers) := (others => 0); begin -- The_Right_Way ... end The_Right_Way; Note that everything in your example is done in the declarative part. -- Jeff Carter "Nobody expects the Spanish Inquisition!" Monty Python's Flying Circus