comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: subtype of enumeration type
Date: 20 Mar 2006 10:37:26 -0500
Date: 2006-03-20T10:37:26-05:00	[thread overview]
Message-ID: <wccbqw1ktzd.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: dvmas1$kj8$1@sunnews.cern.ch

Maciej Sobczak <no.spam@no.spam.com> writes:

> Consider this:
> 
>     type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun);
> 
> and the following standard example:
> 
>     subtype Weekday is Day range Mon .. Fri;
> 
> Now imagine that in some country children don't have to go to school on
> Wednesdays, they go there only Monday, Tuesday, Thursday and Friday.
> 
> I want to say it in Ada.
> 
>     subtype Schoolday is Day <what goes here?>;

You can't do that.

You could put "pragma Assert(Some_Day /= Wednesday)"
all over the place, but that's not quite the same thing.

Eiffel allows arbitrary conditions as invariants,
but Ada has a fairly restricted set of constraints
(ranges for discrete types, a single value for
discriminant constraints, etc).

- Bob



  parent reply	other threads:[~2006-03-20 15:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-20 13:31 subtype of enumeration type Maciej Sobczak
2006-03-20 14:26 ` Larry Kilgallen
2006-03-20 15:18   ` Maciej Sobczak
2006-03-20 15:37 ` Robert A Duff [this message]
2006-03-20 20:29 ` Björn Persson
2006-03-20 21:41 ` Jeffrey R. Carter
2006-03-21  8:37   ` subtypes and preconditions (was: subtype of enumeration type) Peter Amey
2006-03-21 17:42     ` subtypes and preconditions Jeffrey R. Carter
2006-03-21 19:00       ` Georg Bauhaus
2006-03-22  1:54         ` Jeffrey R. Carter
replies disabled

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