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,db88d0444fafe8eb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!feeder.xsnews.nl!81.171.102.20.MISMATCH!eweka!hq-usenetpeers.eweka.nl!68.142.88.75.MISMATCH!hwmnpeer01.ams!news-out.ntli.net!newsrout1-gui.ntli.net!ntli.net!newspeer1-win.ntli.net!newsfe7-win.ntli.net.POSTED!53ab2750!not-for-mail From: "Dr. Adrian Wrigley" Subject: Re: Surprise in array concatenation User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: Newsgroups: comp.lang.ada References: <1125544603.561847.32140@g47g2000cwa.googlegroups.com> <1125610942.747981.280770@f14g2000cwb.googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Date: Sat, 03 Sep 2005 12:51:11 GMT NNTP-Posting-Host: 80.4.127.115 X-Complaints-To: http://www.ntlworld.com/netreport X-Trace: newsfe7-win.ntli.net 1125751871 80.4.127.115 (Sat, 03 Sep 2005 13:51:11 BST) NNTP-Posting-Date: Sat, 03 Sep 2005 13:51:11 BST Organization: ntl Cablemodem News Service Xref: g2news1.google.com comp.lang.ada:4419 Date: 2005-09-03T12:51:11+00:00 List-Id: On Thu, 01 Sep 2005 14:42:22 -0700, Gene wrote: ... > I completely agree with the marginal utility of other-than-1 least > array indices. Like others, I'm surprised to find this is controvertial. People have given some examples already. My favourite examples are: Compatibility with languages that have 0-based arrays. it would be really annoying if indices couldn't be shared between C and Ada arrays, for example. (most C/C++ users see litle utility in other-than-0 least indices!) Ability for subprograms to receive slices of arrays as parameters. C code often has to pass start and stop indices as separate function parameters, in addition to the pointer to the first element. Three parameters instead of one adds clutter. Particularly common in recursive calls. Arrays indexed by modular types. (I know these have been criticised elsewhere). Modular indices are really handy for circular buffers, as well as hash tables and things (pre Ada 200Y!). Arrays indexed by characters (eg a letter frequency table, 'a' .. 'z'). I also use symmetric array indices (eg -10 .. 10) quite a lot for tables indexed by differences. Sometimes negative indices are useful too, (with 0 at the top, usually) (eg -100 .. 0). This is useful for analysing events through relative time. Negative indices are preconditions, positive indices would be postconditions or responses. ( (If you only have positive indices, you find some arrays in your program run forwards through time, and some run backwards. Tracking which is which, and getting the '-' in the right place is particularly error prone) And of course, plenty of contrived examples can be made up, some of which so actually occur in real problems. It's just another area of coding where Ada matches the problem domain, and other languages match the solution domain. Like so many things in Ada, you may not use them every day in some applications, but they're there when you need them! By the way... why aren't fixed point types discrete? The values are integral multiples of small, which can be supplied by the user. So I'd expect to be able to use fixed point types as array indices etc. You cant :( Wouldn't fixed point be *much* more useful if it was discrete? -- Adrian