Re: ADA Popularity Discussion Request
From: Georg Bauhaus (sb463ba_at_l1-hrz.uni-duisburg.de)
Date: 09/09/04
- Next message: Kevin Cline: "Re: ADA Popularity Discussion Request"
- Previous message: Ed Falis: "Re: ADA Popularity Discussion Request"
- In reply to: jayessay: "Re: ADA Popularity Discussion Request"
- Next in thread: jayessay: "Re: ADA Popularity Discussion Request"
- Reply: jayessay: "Re: ADA Popularity Discussion Request"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 9 Sep 2004 01:47:46 +0000 (UTC)
jayessay <nospam@foo.com> 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
- Next message: Kevin Cline: "Re: ADA Popularity Discussion Request"
- Previous message: Ed Falis: "Re: ADA Popularity Discussion Request"
- In reply to: jayessay: "Re: ADA Popularity Discussion Request"
- Next in thread: jayessay: "Re: ADA Popularity Discussion Request"
- Reply: jayessay: "Re: ADA Popularity Discussion Request"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|