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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1901f265c928a511 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!newsfeed.kolumbus.fi!nntp.inet.fi!inet.fi!feeder1.news.jippii.net!reader1.news.jippii.net!53ab2750!not-for-mail Message-ID: <40BCE5E8.4040305@tidorum.fi> From: Niklas Holsti User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020623 Debian/1.0.0-0.woody.1 X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Typing in Ada References: <2i1t1lFij4g5U1@uni-berlin.de> <9ZRuc.8410$hB2.7017@nwrdny03.gnilink.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 01 Jun 2004 23:24:08 +0300 NNTP-Posting-Host: 194.29.197.10 X-Complaints-To: newsmaster@saunalahti.com X-Trace: reader1.news.jippii.net 1086121449 194.29.197.10 (Tue, 01 Jun 2004 23:24:09 EEST) NNTP-Posting-Date: Tue, 01 Jun 2004 23:24:09 EEST Organization: Saunalahti Customer Xref: controlnews3.google.com comp.lang.ada:997 Date: 2004-06-01T23:24:08+03:00 List-Id: Hyman Rosen wrote: > Nick Roberts wrote: > > That is to say that in most Ada > >> programs it is typical to have constructions such as: >> type Apples is range 0..100; >> type Oranges is range 0..200; > > > Is it really? The very fact that you have named these types as > you did suggests that the appplicability of ranged types is quite > limited. In a real program that does something useful, what kinds > of things do you want to count up to 100 but not to 101? To 200 > but not to 201? Can you give examples from some of your real code I'm not the original poster, but here are some examples from real code. I am implementing the mass memory subsystem for a satellite. The mass memory is divided into blocks, pages and octets. There are absolute address in the range 0 .. (total number of octets - 1), block numbers in the range 0 .. (total number of blocks - 1), page numbers likewise, octet offsets within a page, etc, etc. Using strong integer typing I can make the compiler check that I don't, by mistake, try to add a page number to an octet offset or do other equally senseless things. To return to Nick Robert's example, the numbers 100 and 200 should either come from the requirements specification ("The program shall be able to count up to 100 apples and 200 oranges...") or should appear in the software user manual ("The program can count up to 100 apples and 200 oranges"). So then it is clear that the program satisfies its requirements (or it won't compile) and satisfies its user manual, whatever range Standard.Integer has on the current platform. Niklas Holsti