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,ab3fadb7cac7363c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!feeder.erje.net!news2.arglkargh.de!news.tornevall.net!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Address arithmetic alternatives Date: Thu, 09 Jun 2011 11:53:01 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: <57e75a35-058c-4172-9a3d-e11e7c5f7697@l2g2000prg.googlegroups.com> <70bda46e-e016-42e8-a0bb-7003ec1488ec@r33g2000prh.googlegroups.com> <6355779b-dab3-4f78-a6f7-78f395426332@v8g2000yqb.googlegroups.com> <5bf3d787-c0b0-45c7-841f-0f08c93a3655@e26g2000vbz.googlegroups.com> NNTP-Posting-Host: dd997864c9b2af7da02da8fcad5e1d0f Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: 580c1fdc3457b6402aa985a6463745e7 X-Complaints-To: abuse@tornevall.net User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: <5bf3d787-c0b0-45c7-841f-0f08c93a3655@e26g2000vbz.googlegroups.com> X-UserIDNumber: 1738 X-Validate-Post: http://news.tornevall.net/validate.php?trace=580c1fdc3457b6402aa985a6463745e7 X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news1.google.com comp.lang.ada:19719 Date: 2011-06-09T11:53:01-07:00 List-Id: On 06/09/2011 03:40 AM, milouz wrote: > >> More correctly, you *think* you need to play with address arithmetic. You may be >> right, but address arithmetic is needed extremely rarely in Ada. Ada has >> alternatives to most address arithmetic in C. > > You're probably right. But what are those alternatives ? That depends on what you're trying to do. Probably the most common is (I apologize if my C is wrong) p = a; while (*p++) { /* do something with *p */ } (which is wrong any since "a" may not contain a zero, and you go off accessing memory you shouldn't. This kind of thing is why C coders are creating yet more buffer-overflow vulnerabilities even as I type) In Ada, one uses indexing: for I in A'range loop -- Do something with A (I). end loop; -- Jeff Carter "I was hobbling along, minding my own business, all of a sudden, up he comes, cures me! One minute I'm a leper with a trade, next minute my livelihood's gone! Not so much as a 'by your leave!' You're cured, mate. Bloody do-gooder!" Monty Python's Life of Brian 76