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,71c41b6f4d72158c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-07-16 01:18:55 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!newspeer.cts.com!galanthis.cts.com!127.0.0.1.MISMATCH!not-for-mail Sender: kst@king.cts.com Newsgroups: comp.lang.ada Subject: Re: if X in 1..35000 versus Boolean References: From: Keith Thompson Date: 16 Jul 2002 01:18:54 -0700 Message-ID: X-Newsreader: Gnus v5.7/Emacs 20.7 NNTP-Posting-Host: 209.68.192.180 X-Trace: 1026807534 nntp.cts.com 317 209.68.192.180 Xref: archiver1.google.com comp.lang.ada:27134 Date: 2002-07-16T01:18:54-07:00 List-Id: Jan Prazak writes: > On Sat, 13 Jul 2002 15:27:03 -0100, Frank J. Lhota wrote: > > Also, 1 .. 35000 is an integer range, not an enumeration type. > > But the word "in" tests, if given object (variable...) is > in given enumeration type. > > type num : (1, 2, 3, 4); > > if 3 in num then ... > > -- this should be the same as: if 3 in (1,2,3,4); > -- and also the same as: if 3 in 1..4; > > So I assume that "if X in 1..35000" has the same rules. I think you're thinking of Pascal sets, not enumeration types. Ada doesn't have built-in set types, though they're easy enough to implement. If I recall correctly (it's been a while), in Pascal you can write something like: if X in [1 .. 4] then (* This is Pascal, not Ada *) begin ...; end; where [1 .. 4] is a set value constructor. A naive Pascal compiler would build a set value with bits 1, 2, 3, and 4 set, and all other bits cleared, and test whether bit X is set. A more clever Pascal compiler might generate code equivalent to X >= 1 and X <= 4. You can also do more complex things like if X in [1 .. 4, 7 .. 9, 12] then (* This is Pascal, not Ada *) begin ...; end; The Ada construct 1 .. 4 is *not* a set value constructor, it's a range. Given the condition "X in 1 .. 4", there's no reason for the compiler to generate anything more complicated than "X >= 1 and X <= 4". There is no direct Ada equivalent to "X in [1..4, 7..9, 12]". An enumeration type is something else; for example: type Color is (Red, Blue, Green); Note that the values are identifiers, not numeric literals. I suggest you find a good Ada textbook or online tutorial. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> Schroedinger does Shakespeare: "To be *and* not to be"