comp.lang.ada
 help / color / mirror / Atom feed
From: "Anders Wirzenius" <anders.wirzenius@pp.qnet.fi>
Subject: Re: Types, subtypes and ranges
Date: Tue, 13 Mar 2001 06:40:00 GMT
Date: 2001-03-13T06:40:00+00:00	[thread overview]
Message-ID: <4hjr6.34$6Z3.1464@read2.inet.fi> (raw)
In-Reply-To: 98idi9$66g$1@hobbes2.crc.com

David C. Hoos, Sr. wrote in message <98idi9$66g$1@hobbes2.crc.com>...
>Because TTT'Image is inherited from its base type T.
>
>If you had declared TT and TTT as new T types, the constraint
>error would have occurred, but then you wouldn't have been
>able to add anders to banders without type conversion, because
>the types would have been distinct.

Thanks

I deleted my former code but include my further studies on the subject. It
showed me that the 'Image attribute is inherited all the way up as long as
you don't break the chain of subtypes:

with Ada.Text_IO;
procedure Why_Not_Constraint_Error is
   type T is new Integer;
   subtype TT is T range -2..-1;
   subtype TTT is T range -1..+1;
   subtype TTTT is TTT range -1..0;
   subtype TTTTT is TTTT range 0..0;
   anders : TT := -2;
   bnders : TTTT := 0;
   use Ada.Text_IO;
begin
   Put ( TTTTT'Image ( anders+bnders ) );
end Why_Not_Constraint_Error;

Anders





  parent reply	other threads:[~2001-03-13  6:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-03  1:00 Questions: WM
2001-03-03  3:30 ` Questions: Robert Love
2001-03-03 11:09 ` Questions: David C. Hoos, Sr.
2001-03-07 23:05 ` Questions: Mark Lundquist
2001-03-08  1:14   ` Questions: Robert A Duff
2001-03-12  7:41   ` Types, subtypes and ranges Anders Wirzenius
2001-03-12 11:57     ` David C. Hoos, Sr.
2001-03-12 16:06       ` Tucker Taft
2001-03-13  6:40       ` Anders Wirzenius [this message]
2001-03-12 16:57     ` Scott Ingram
2001-03-18 22:28     ` Lao Xiao Hai
2001-03-19 13:22       ` Marc A. Criley
2001-03-20 16:57         ` Lao Xiao Hai
  -- strict thread matches above, loose matches on Subject: below --
2001-03-14 13:50 Christoph Grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox