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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,da3af210412d89fd X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!newsfeed2.dallas1.level3.net!newsfeed1.dallas1.level3.net!news.level3.com!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Range types Reply-To: anon@anon.org (anon) References: <1192994157.867598@athprx04> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Sun, 21 Oct 2007 21:53:56 GMT NNTP-Posting-Host: 12.64.60.38 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1193003636 12.64.60.38 (Sun, 21 Oct 2007 21:53:56 GMT) NNTP-Posting-Date: Sun, 21 Oct 2007 21:53:56 GMT Organization: AT&T Worldnet Xref: g2news2.google.com comp.lang.ada:2532 Date: 2007-10-21T21:53:56+00:00 List-Id: -- -- From the syntax rules of RM 3.2.1, 3.2.2 and 3.5 the -- simple answer is no for integer scalar types. -- -- One way to do this is to exclude the values you want -- in the logical of the program -- with Ada.Text_IO ; use Ada.Text_IO ; procedure t is -- -- creates a master constraint type -- type My_Int_Base is range 1..200 ; -- -- creates an excluded type -- subtype My_Int_Exclude_Subtype is My_Int_Base range 101..149 ; Var_0 : My_Int_Base ; begin -- set Var_0 valid Put_Line ( "Var_0 => 75" ) ; Var_0 := 75 ; -- -- Verify that value of Var_0 is not excluded -- if Var_0 in My_Int_Exclude_Subtype then raise Constraint_Error ; end if ; -- -- Use Var_0 -- Put_Line ( " Var_0 => Valid" ) ; -- -- Set Var_0 invalid -- Put_Line ( "Var_0 => 125" ) ; Var_0 := 125 ; -- -- Verify that value of Var_0 is not excluded -- if Var_0 in My_Int_Exclude_Subtype then raise Constraint_Error ; end if ; -- -- Use Var_0 -- Put_Line ( " Var_0 => Valid" ) ; exception when Constraint_Error => Put_Line ( " Var_0 => Constraint_Error" ) ; end t ; In <1192994157.867598@athprx04>, Christos Chryssochoidis writes: >Hi, > >I have a question regarding the range types in Ada. Is there any way to >specify that a type is, say, the values 1..100 and additionally the >values 150..200? I tried something like > >> type My_Int is range 1..100, 150..200; > > > >and > >> type My_Int is range 1..100 | 150..200; > > >but without success. I also tried doing this within an enumeration, but >failed again. Is it possible to define such type, consisting of multiple >ranges? > > >Thanks very much for any answer. > > >Christos Chryssochoidis