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,bbe592428babd509 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!weretis.net!feeder3.news.weretis.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 27 Apr 2010 14:22:00 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Web browser in Ada References: <02c2bf63-260d-4acc-bd58-c8fb8a591ec3@b6g2000yqi.googlegroups.com> <0bf9425c-32a1-4b93-b938-ae4a4e24a761@c21g2000yqk.googlegroups.com> <4bd1b090$0$7651$9b4e6d93@newsspool1.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Message-ID: <4bd6d6e8$0$6892$9b4e6d93@newsspool2.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 27 Apr 2010 14:22:01 CEST NNTP-Posting-Host: 095755e7.newsspool2.arcor-online.net X-Trace: DXC=InM24HnVHWB^B]`=U:WelBA9EHlD;3YcB4Fo<]lROoRA8kFJLh>_cHTX3jMJ9HC0H7acUC X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:11204 Date: 2010-04-27T14:22:01+02:00 List-Id: On 27.04.10 13:41, Martin Krischik wrote: > Am 23.04.2010, 16:37 Uhr, schrieb Georg Bauhaus > : > >> On 23.04.10 15:56, Maciej Sobczak wrote: > >> BTW, why do we still subscribe to the notion "integer overflow" >> when the one thing that any sequence of what is commonly known >> as integers cannot possibly do is to overflow? Maybe the >> wording is at the heart of the problem. > > Not at all. This is an integer overflow: > > int dayOfMonth = 32; I don't think that this is an integer overflow by the common definition of "integer overflow" (which relies on "int", not implications of the name "dayOfMonth" ---and also not on "integer"). No overflow there, just a terrible programming mistake. In Ada, other than predefined "Integer" and such, there are no named integer types. Good thing, as this lack suggests adding at least range constraints, if not new types. In C, many programmers seem to think there are integers and that their name is "int". (On a 5bit architecture one could even be mislead to believe that the above declaration would create overflow (disregarding the logical error), since 32 > 2^5 - 1. But I think that C's minimum requirement for an "int" is storing values between -(2^15 - 1) and +(2^15 - 1)--- whatever width the underlying hardware's words do actually have.) So the above would "flow over" the range constraint of a suitably defined Month subtype in Ada. (Forgetting about February problems for the moment, that can only to be solved in type systems such as Qi's.) > Simplified example of course. Uhm, the heart of the problem is that "int" is taken to mean, ..., well, ... an integer? Yes, the above is a logical error, one that could have been prevented mechanically by using a good base type system, one that does not include "the integers". Which is my point: that it is a misconception to think of "int" as an integer. If you think of "int" as what it is: "int", and if you are smart, then little can go wrong. This is easier to get right once you have a base type system that naturally suggest not to think in terms of an infinite set of arbitrary high school numbers, but of computer entities. Like Ada's. I like this characterization of C's int: "The int type was typically the most convenient native data type for integer math." (*) The "native" part is what seems lost in stereotypical C knowledge. (*) http://www.ibm.com/developerworks/power/library/pa-ctypes3/index.html