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,fad7742cc8dcbb84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: type and subtype References: <1122215078.559279.16980@f14g2000cwb.googlegroups.com> <87mzocrx9d.fsf@insalien.org> In-Reply-To: <87mzocrx9d.fsf@insalien.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <_vPEe.3516$Uk3.77@newsread1.news.pas.earthlink.net> Date: Sun, 24 Jul 2005 16:40:26 GMT NNTP-Posting-Host: 209.86.18.231 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1122223226 209.86.18.231 (Sun, 24 Jul 2005 09:40:26 PDT) NNTP-Posting-Date: Sun, 24 Jul 2005 09:40:26 PDT Xref: g2news1.google.com comp.lang.ada:3742 Date: 2005-07-24T16:40:26+00:00 List-Id: Ludovic Brenta wrote: > > Two subtypes of the same type are compatible with one another. One > can convert between them using an implicit type conversion (i.e. no > special syntax required). There is no type conversion between subtypes of the same type, since they are the same type. There are checks that the value of the source matches the constraints of the destination. Consider: type Year_Number is range 1901 .. 2099; type Month_Number is range 1 .. 12; Y : Year_Number := 2000; M : Month_Number := 6; procedure P (Y : in Year_Number); ... Y := M; -- illegal, different types P (Y => Y + M); -- illegal, no such "+" and then: subtype Year_Number is Integer range 1901 .. 2099; subtype Month_Number is Integer range 1 .. 12; Y : Year_Number := 2000; M : Month_Number := 6; procedure P (Y : in Year_Number); ... Y := M; -- legal, same type P (Y => Y + M); -- legal, "+" (Left, Right : Integer) return Integer; -- Y + M in Year_Number M := 12; M := 2 * M - M; -- legal, operations evaluated for type (Integer) -- result in Month_Number -- Jeff Carter "I like it when the support group complains that they have insufficient data on mean time to repair bugs in Ada software." Robert I. Eachus 91