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,9ab1bf4be2d855dd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-11 23:46:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!oleane.net!oleane!jussieu.fr!opentransit.net!news.tele.dk!194.255.56.67!newsfeed101.telia.com!newsrouter.euroconnect.net!news.clinet.fi!news.cs.hut.fi!newsfeed3.funet.fi!newsfeed1.funet.fi!newsfeeds.funet.fi!nntp.teliafi.net!nntp.inet.fi!central.inet.fi!inet.fi!read2.inet.fi.POSTED!not-for-mail From: "Anders Wirzenius" Newsgroups: comp.lang.ada References: <97pfmt$ll30@tech.port.ac.uk> Subject: Types, subtypes and ranges X-Newsreader: Microsoft Outlook Express 4.72.3110.5 X-Mimeole: Produced By Microsoft MimeOLE V4.72.3110.3 Message-ID: Date: Mon, 12 Mar 2001 07:41:41 GMT NNTP-Posting-Host: 194.251.142.2 X-Trace: read2.inet.fi 984382901 194.251.142.2 (Mon, 12 Mar 2001 09:41:41 EET) NNTP-Posting-Date: Mon, 12 Mar 2001 09:41:41 EET Organization: Sonera corp Internet services Xref: supernews.google.com comp.lang.ada:5629 Date: 2001-03-12T07:41:41+00:00 List-Id: Mark Lundquist wrote in message ... >Sorry for the late response (I lost access to news for a while...) > >WM wrote in message >news:97pfmt$ll30@tech.port.ac.uk... >> Hi, I am an ada beginner. Can anyone kindly tell me what's the difference >> between TYPE and SUBTYPE? > ... > subtype S is T; > >declares a new subtype S of the type of subtype T. This is also an example >of a subtype declaration that does not include a constraint, so the >constraint of S is the same as the constraint of T. (This is how you >"rename" or create an alias for a type). What a subtype declaration looks >like that adds a constraint depends on the type of the subtypes, e.g. for an >integer type you might have May I continue with two more questions: 1. given > > subtype S is T range 1 .. 10; what is the the difference between the above declaration and type S is new T range 1..10; 2. Why don't I get a constraint_error in the following code where I violate the range of type TTT in the Put statement? 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; anders : TT := -2; bnders : TTT := -1; use Ada.Text_IO; begin Put ( TTT'Image ( anders+bnders ) ); end Why_Not_Constraint_Error; Anders another beginner