From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: types and subtypes
Date: Mon, 13 Mar 2006 14:20:43 +0100
Date: 2006-03-13T14:20:43+01:00 [thread overview]
Message-ID: <bjr3vd.ep4.ln@hunter.axlog.fr> (raw)
In-Reply-To: <1142251677.837212.109000@i39g2000cwa.googlegroups.com>
ada_student@yahoo.com a �crit :
> Given,
>
> subtype Positive is Integer range 1 .. Integer'Last;
> type String is (Positive range <>) of Character;
>
> the following should be illegal,
>
> subtype Count_To_Ten is Integer range 1 .. 10;
> subtype Ten_Characters is String (Count_to_Ten);
>
> and the following should be legal, instead
>
> subtype Count_To_Ten is Positive range 1 .. 10;
> subtype Ten_Characters is String (Count_to_Ten);
>
> Why is Count_To_Ten allowed to be an Integer even though
> the indices of String are declared as Positives?
>
Because they are of the same *type*. A subtype does not declare a
different type, only a restriction (a *constraint*) on the allowed
values. Since the types are the same, the declaration is OK.
--
---------------------------------------------------------
J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
next prev parent reply other threads:[~2006-03-13 13:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-13 12:07 types and subtypes ada_student
2006-03-13 13:20 ` Jean-Pierre Rosen [this message]
2006-03-13 18:08 ` ada_student
2006-03-13 18:17 ` Ed Falis
2006-03-13 19:14 ` Larry Kilgallen
2006-03-13 19:42 ` Martin Krischik
2006-03-13 20:22 ` Wilhelm Spickermann
2006-03-14 8:47 ` Dmitry A. Kazakov
2006-03-14 14:39 ` Jean-Pierre Rosen
2006-03-17 1:24 ` Peter C. Chapin
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox