comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: enumration using integers?
Date: Fri, 20 Apr 2001 18:18:17 GMT
Date: 2001-04-20T18:18:17+00:00	[thread overview]
Message-ID: <J3%D6.4521$D4.464878@www.newsranger.com> (raw)
In-Reply-To: 3AE04917.DF97BEA0@emw.ericsson.se

In article <3AE04917.DF97BEA0@emw.ericsson.se>, Sven Nilsson says...
>
>Ted Dennison wrote:
>> Hmm. I don't see anything in the above that couldn't have been done by making
>> Distance a sybtype of Integer. Are you saying that you just want an integer type
>> with "holes" in it, so that
>> Dist := 2;
>> would raise a Constraint_Error?
>
>Yepp, that sounds about right. I've been looking for something like that
>in Barnes but I couldn't find it... Any clue?

Ahhh. We have had that discussion here before. If I recall, the consensus was
that there isn't a way to do that which would generally be worth the effort. If
its really important to you to detect invalid assignments in the middle, then
make it private and write your own "assign" routine that checks. 

You can write your own operation to happen upon every " := ", but that requires
that the type be derived from the type Ada.Controlled, which means that it has
to be a tagged type declared in a library-level package spec. You'd also have to
create your own "+", "-", "*", ect. For a simple integer, again probably not
worth the effort.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  parent reply	other threads:[~2001-04-20 18:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-19 10:58 enumration using integers? Sven Nilsson
2001-04-19 12:42 ` Marc A. Criley
2001-04-19 13:02 ` Philip Anderson
2001-04-19 14:50 ` Ted Dennison
2001-04-20  5:22   ` Sven Nilsson
2001-04-20 13:57     ` Ted Dennison
2001-04-20 14:35       ` Sven Nilsson
2001-04-20 15:50         ` Keith Thompson
2001-04-20 18:18         ` Ted Dennison [this message]
2001-04-20 15:52     ` Samuel T. Harris
replies disabled

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