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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,68ab861309518ae8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-20 11:18:28 PST Path: supernews.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!news-out.nuthinbutnews.com!propagator!feed2.newsfeeds.com!newsfeeds.com!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison Sender: usenet@www.newsranger.com References: <3ADEC4E8.954B6830@emw.ericsson.se> <3ADFC797.7D2D537D@emw.ericsson.se> <3AE04917.DF97BEA0@emw.ericsson.se> Subject: Re: enumration using integers? Message-ID: Date: Fri, 20 Apr 2001 18:18:17 GMT NNTP-Posting-Host: 209.208.22.130 X-Complaints-To: abuse@newsranger.com X-Trace: www.newsranger.com 987790697 209.208.22.130 (Fri, 20 Apr 2001 14:18:17 EDT) NNTP-Posting-Date: Fri, 20 Apr 2001 14:18:17 EDT Organization: http://www.newsranger.com Xref: supernews.google.com comp.lang.ada:7050 Date: 2001-04-20T18:18:17+00:00 List-Id: 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