comp.lang.ada
 help / color / mirror / Atom feed
From: "Lance" <lanceboyle@qwest.net>
Subject: Re: Compare these two (sub)type declarations
Date: 4 Jul 2006 13:01:10 -0700
Date: 2006-07-04T13:01:10-07:00	[thread overview]
Message-ID: <1152043270.449772.302270@j8g2000cwa.googlegroups.com> (raw)
In-Reply-To: 1152008738.616133.149850@m79g2000cwm.googlegroups.com


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.




  reply	other threads:[~2006-07-04 20:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-04  9:46 Compare these two (sub)type declarations Lance
2006-07-04 10:25 ` Ludovic Brenta
2006-07-04 20:01   ` Lance [this message]
2006-07-04 21:13     ` spam countermeasures (was: Compare these two (sub)type declarations) Björn Persson
2006-07-05 17:42 ` Compare these two (sub)type declarations Martin Krischik
replies disabled

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