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,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!news.netcologne.de!newsfeed-fusi.netcologne.de!151.189.20.20.MISMATCH!newsfeed.arcor.de!news.arcor.de!not-for-mail Date: Fri, 25 Mar 2005 02:02:19 +0100 From: Georg Bauhaus User-Agent: Debian Thunderbird 1.0 (X11/20050116) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) References: <1110284070.410136.205090@o13g2000cwo.googlegroups.com> <395uqaF5rhu2mU1@individual.net> <1110329098.642196@athnrd02> <1110361741.551255@athnrd02> <422edaec$0$26554$9b4e6d93@newsread4.arcor-online.net> <1111464133.508323@athnrd02> <423fe9df$0$11476$9b4e6d93@newsread2.arcor-online.net> <1111521825.653841@athnrd02> <424094b0$0$11481$9b4e6d93@newsread2.arcor-online.net> <1111568404.687226@athnrd02> <42416659$0$11476$9b4e6d93@newsread2.arcor-online.net> <1111611226.253249@athnrd02> <4241f47a$0$24073$9b4e6d93@newsread4.arcor-online.net> <1111627358.387482@athnrd02> <424222df$0$24057$9b4e6d93@newsread4.arcor-online.net> <1111632436.374702@athnrd02> <1111698643.735412.144620@l41g2000cwc.googlegroups.com> In-Reply-To: <1111698643.735412.144620@l41g2000cwc.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <424362cc$0$11478$9b4e6d93@newsread2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 25 Mar 2005 02:01:00 MET NNTP-Posting-Host: c9a5a0a8.newsread2.arcor-online.net X-Trace: DXC=[`W]fEjjo]72j7j^L?86D8Q5U85hF6f;4jW\KbG]kaM8]kI_X=5Kea6LT_WhS3>if9hP3YJKgE\j<6_3^O8HIQP< X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:9939 comp.lang.c++:47142 comp.realtime:1694 comp.software-eng:5305 Date: 2005-03-25T02:01:00+01:00 List-Id: T Beck wrote: > I'm with Ioannis on this one... I fail to see how p[-1] is any less an > index on an array than somearray[1] is. One difference is a 1:1 correspondence of index values and indexed items. This suggests not using p[-1] or somearray[1] interchangeably: There is one named index type. There is one named array type. The index type is used in the declaration of the array type, stating the set of permissible array index values. type Item_Array is array (Index_Type) of Item; Values in the index type designate items in the problem domain. This propagates into the declaration of the array type. It also propagates into its use. Ioannis really started, I think, from this 1:1 correspondence. He had (intuitively?) mapped these kinds of array to std::map in sample programs. Conceptually this seems right because the specific index values and the items are associated 1:1 in the array. From this perspective, after choosing an associative container for representing the (index, item) pairs, you can no longer use somemap[-1] or somemap[1] interchangeably. The perspective has shifted from computing offsets to an association. 1 is associated with one item in the array, -1 is associated with another. In this sense, p[-1] and somearray[1] are different. In a sense, -1 and 1 are treated as names rather than computable index values. (Ada-like arrays have STL's key_type so to speak.) Georg