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,c406e0c4a6eb74ed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news.cs.univ-paris8.fr!informatik.uni-bremen.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: ADA Popularity Discussion Request Date: Sat, 11 Sep 2004 11:44:56 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <49dc98cf.0408110556.18ae7df@posting.google.com> <413e2fbd$0$30586$626a14ce@news.free.fr> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1094903096 24870 134.91.1.34 (11 Sep 2004 11:44:56 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Sat, 11 Sep 2004 11:44:56 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: g2news1.google.com comp.lang.ada:3584 Date: 2004-09-11T11:44:56+00:00 List-Id: Kevin Cline wrote: : I don't know. It could be done in C++ if Some_Index_Type had the : right properties. But as a practical matter, no one seems to care, at : least no one in the C++ community. Could it be an effect of tradition? If C++ had not inherited C arrays, maybe arrays (including dynamically sized) were used more frequently? I guess vector is used for array computation, then? : I very rarely have any need or use : for a statically sized array. If you need _dynamically_ sized arrays you still can have subtypes with bounds determined at run time. I think this can be important. (C99 now has some of it.) Declare the subtypes locally as index types, ranges based on runtime values. Declare dynamically or statically sized arrays in blocks, in functions, wherever. Create corresponding arrays on the stack or on the heap, assign the results ... type Vec is array (Positive range <>) of Natural; -- base type of all "vectors" counting from 1 function make(limit: Positive; init: Natural := 0) return Vec -- a dynamically sized `Vec`, all values set to `init` is subtype Index is Positive range Positive'first .. limit; subtype A is Vec(Index); begin return A'(others => init); end make; x: Vec := make(5); pragma assert(x'first = 1 and x'last = 5); -- Georg