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,bfa00be8f7a5ae46 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!j8g2000cwa.googlegroups.com!not-for-mail From: "Lance" Newsgroups: comp.lang.ada Subject: Re: Compare these two (sub)type declarations Date: 4 Jul 2006 13:01:10 -0700 Organization: http://groups.google.com Message-ID: <1152043270.449772.302270@j8g2000cwa.googlegroups.com> References: <1152006378.935306.287820@m79g2000cwm.googlegroups.com> <1152008738.616133.149850@m79g2000cwm.googlegroups.com> NNTP-Posting-Host: 63.229.83.84 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1152043276 28389 127.0.0.1 (4 Jul 2006 20:01:16 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 4 Jul 2006 20:01:16 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: j8g2000cwa.googlegroups.com; posting-host=63.229.83.84; posting-account=Ax24hA0AAABV39UFqUVhb0kauOuAbI3T Xref: g2news2.google.com comp.lang.ada:5490 Date: 2006-07-04T13:01:10-07:00 List-Id: Ludovic Brenta wrote: > Lance writes : > > What is the difference between these two declarations? > > > > subtype Foo is Integer; > > Foo is a subtype. It is compatible with Integer and with all other > subtypes of Integer such as Natural and Positive, i.e. you can convert > implicitly between all these subtypes. The compiler inserts range > checks where appropriate. > > > and > > > > type Bar is new Integer; > > > > In fact, what _is_ the second declaration? Would variables of type Bar > > not be allowed in expressions where Integers are expected? > > Bar is a derived type. It is not compatible with Integer, or with any > subtype of Integer, so the compiler would reject a program that passes > a Bar to a subprogram that expects an Integer. You can, however, > convert _explicitly_ between Bar and Integer, just like between any two > numeric types; the compiler inserts range checks as appropriate. > > HTH > > > Jerry > > Is it Lance, or Jerry now? > My name is Jerry B a u c k. I use the lanceboyle address for mailing lists for spam control reasons (lance boil is a joke in English) and to keep from polluting my "real namespace" on the internet. I always sign as Jerry but surprisingly (to me), people usually reply to "Lance." I live in Tempe, Arizona, USA where I am self-employed. Thanks for your informative reply. > -- > Ludovic Brenta.