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: a07f3367d7,c9d5fc258548b22a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!news.nobody.at!texta.sil.at!newsfeed01.chello.at!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 08 Feb 2011 10:46:18 +0100 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.14) Gecko/20110123 Thunderbird/3.1.8 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How do I write directly to a memory address? References: <67063a5b-f588-45ea-bf22-ca4ba0196ee6@l11g2000yqb.googlegroups.com> <31c357bd-c8dc-4583-a454-86d9c579e5f4@m13g2000yqb.googlegroups.com> <05a3673e-fb97-449c-94ed-1139eb085c32@x1g2000yqb.googlegroups.com> <8r86vgFc3uU1@mid.individual.net> <19fh1chm74f9.11cws0j5bckze.dlg@40tude.net> <4d4ff70e$0$6886$9b4e6d93@newsspool2.arcor-online.net> <737a6396-72bd-4a1e-8895-7d50f287960e@d28g2000yqc.googlegroups.com> <4d5008a5$0$6879$9b4e6d93@newsspool2.arcor-online.net> <4d5031fe$0$6765$9b4e6d93@newsspool3.arcor-online.net> <1f229967-d3cf-42b6-8087-c97ee08652f3@i40g2000yqh.googlegroups.com> In-Reply-To: <1f229967-d3cf-42b6-8087-c97ee08652f3@i40g2000yqh.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4d5110ea$0$7669$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 08 Feb 2011 10:46:18 CET NNTP-Posting-Host: 259d57fc.newsspool1.arcor-online.net X-Trace: DXC=5i6>2Pe\8SZaoembcbF;DQic==]BZ:af^4Fo<]lROoRQ<`=YMgDjhgRgJjA2iN6XiVPCY\c7>ejVXK5<5`F_\_8XZa[6noZNmWW X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:17939 Date: 2011-02-08T10:46:18+01:00 List-Id: On 2/8/11 9:04 AM, Ludovic Brenta wrote: >> Ease of implementation when pushing parameters? >> >> void foo(int countdown) >> { >> while (--countdown) { >> fputc('.', stdout); >> } >> fputc('\n', stdout); >> } > > That's what I meant by "variants of premature optimization". If all > parameters were const, as in Ada, the programmer would simply declare > a local variable, like in Ada. And the bug I was talking about would > become blatantly obvious. As I said, maybe that was easier to implement for the C language and compiler makers. You'd have to demonstrate that an Ada procedure, needing an extra loop variable, will produce the same code. (Hopefully, it does not!) > BTW, like I said, *every* time I look at C code, I see a bug. In your > case, foo has undefined behavior if countdown is negative. We are playing Monopoly, aren't we. You won't be winning a single C programmer with this style of non-framed single issue logic triggered only by stupid misuse of a perfectly working solution. As Hyman said, there are tons of well working C programs out there, very likely using some int i, plus increment or decrement. Well, there is a related CVE every other week, but (a) there aren't equally many Ada programs, (b) if programmers don't know what INT_MAX + 1 is, they shouldn't be programming in C, and (c) by single case logic, Ada's type system has not prevented deaths in Ariane 5 anyway.