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!news3.google.com!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Peter Amey Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) Date: Thu, 24 Mar 2005 11:24:49 +0000 Message-ID: <3afmc2F6b3mooU1@individual.net> References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <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> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 0MBzc5ZXdEmuS4m9216BtQypQ7ucdJ+8XaiFUuQAQ1gYnoPdM= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en In-Reply-To: <1111568404.687226@athnrd02> Xref: g2news1.google.com comp.lang.ada:9897 comp.lang.c++:47042 comp.realtime:1677 comp.software-eng:5282 Date: 2005-03-24T11:24:49+00:00 List-Id: Ioannis Vranos wrote: [snip] > > At first, it is easy to write a container in C++ that accepts a > specified range for indexes. The only reason that there is not one, is > because it does not make sense in C++ (when I learned some Pascal in the > past, I could not understand what was the use of the ability to use > negative indexes in arrays. The [0, +] style maps closely what is > happening in the machine. Of all the comments in this rambling (but remarkably bloodless) thread, this is the one that, for me, gets closest to the fundamental philosophical difference between the C language family and Ada. The [0, +] styles does indeed map closely to what is happening in the machine; however, for me, what is happening in the machine is generally much less interesting than what is being represented in my problem domain. I am always struck by the way a C user's first thought always seems to be about how many bits he needs to represent something where an Ada user is concerned with real-world values and leaves the bit size to be chosen by the compiler. Of course, when writing an interface to a hardware device, we have to worry about bit patterns but I certainly want to stop doing that as soon as possible and worry about the problem domain instead. So, for an array, I want to index it with a problem domain entity and let the compiler turn that into a wholy uninteresting set of address offsets. Ionnis wanted an example of negative indexes. How about: type X_Values is range -5 .. 5; type Y_Values is range 0 .. 25; type Graph is array (X_Values) of Y_Values; Squares : constant Graph := (25, 16, 9, 4, 1, 0, 1, 4, 9, 16, 25); > > [snip] Peter