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-13 09:44:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!hse-mtl-ppp74617.qc.sympatico.CA!not-for-mail From: Christopher Browne Newsgroups: comp.lang.ada Subject: Re: if X in 1..35000 versus Boolean Date: 13 Jul 2002 16:44:21 GMT Organization: cbbrowne Computing Inc Message-ID: References: NNTP-Posting-Host: hse-mtl-ppp74617.qc.sympatico.ca (64.229.209.140) X-Trace: fu-berlin.de 1026578661 24733735 64.229.209.140 (16 [125932]) X-Draft-From: ("nnvirtual:Languages" 526) X-Home-Page: http://www.cbbrowne.com/info/ X-Emacs-Acronym: Extraneous Macros And Commands Stink Microsoft: We've got the solution for the problem we sold you. X-Shopping-List: (1) Puddle-Off! Selectors (2) Pendulous ravenous exclamation attention (3) Pyrotechnical transient confessions (4) Vehement respectable witches X-Uboat-Death-Message: TORPEDOED BY CORVETTE. CREW UNMOTIVATED. SINKING. U-895. Xref: archiver1.google.com comp.lang.ada:27052 Date: 2002-07-13T16:44:21+00:00 List-Id: The world rejoiced as Jan Prazak wrote: > Hello, > > I have a simple question: > > does the compiler (I am using GNAT) "see", that > if X in 1..35000 then > > is the same as > if (X >= 1) and (X <= 35000) then > > ??? > > Or does the compiler really create an enumeration type with 35000 entries > with values from 1 to 35000, just to check if X is in there??? I just changed a "if (fsm < proposal) and ..otherstuff.." to "if (fsm in 1..proposal) and ...otherstuff..." in a prime number sieve. The size of the object code increased by 20 bytes, so it evidently changed _something_. I'll bet that it created an anonymous enumeration type, and that some extra code is describing/referencing that. But it appears that optimization does The Right Thing so that the result amounts to "X in 1..35000" ultimately being transformed into something rather resembling "(X >= 1) and (X <= 35000)". -- (concatenate 'string "cbbrowne" "@cbbrowne.com") http://www3.sympatico.ca/cbbrowne/pascal.html The IETF motto: "Rough consensus *and* working code."