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,c406e0c4a6eb74ed X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!news.cs.univ-paris8.fr!informatik.uni-bremen.de!cs.tu-berlin.de!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: ADA Popularity Discussion Request Date: Thu, 9 Sep 2004 01:47:46 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <49dc98cf.0408110556.18ae7df@posting.google.com> <87eklg62x8.fsf@news.bourguet.org> NNTP-Posting-Host: l1-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1094694466 14482 134.91.1.34 (9 Sep 2004 01:47:46 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Thu, 9 Sep 2004 01:47:46 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/800)) Xref: g2news1.google.com comp.lang.ada:3523 Date: 2004-09-09T01:47:46+00:00 List-Id: jayessay wrote: : Yes, and they don't happen at runtime if pre and post are checked : during incremental development. If you don't do this, then you will : likely have problems - just like if you don't get the types right in : static languages. Is it really much more time efficient, if pre and post checking is done by an incrementing human? If so, how much? : Your explanation above does not cover the logic error. I don't see : right off how modular types catch that. See below, there isn't a logic error, only a typo. : with Text_Io; use Text_Io; : : procedure Foo is : : type Hex_Num is mod 16; : : function Hext (N : Integer) return Hex_Num is : begin : -- == (1+ (n mod 16)), which is the logic error. ^^^^^^^^^^^^ not really, see below : return Hex_Num(1 + (N mod Hex_Num'Modulus)); : end Hext; : : begin : for I in 0..20 loop : Put_Line("Answer is: " & Hex_Num'Image(Hext(i))); Put_Line("Answer is: " & Integer'Image(Hext(i))); : end loop; : end; In the Lisp example there was a "typo context". "next" should have been where "hext" was actually typed in the Lisp example. Therefore, an integer number was actually wanted ("next"), not a hex number ("hext"). So there must be an Integer'image reflecting the logic/expectation ("next") not a Hex_Num'image (typo "hext"). The error is caught by the compiler. 15. Put_Line("Answer is: " & Integer'Image(Hext(i))); | >>> expected type "Standard.Integer" >>> found type "Hex_Num" defined at line 4 -- Georg