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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38159b1b5557a2e7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-01-23 21:53:32 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!zeus.visi.com!news-out.visi.com!green.octanews.net!news.octanews.net!news-xfer.cox.net!peer02.cox.net!cox.net!pd7cy1no!pd7cy2so!shaw.ca!border1.nntp.ash.giganews.com!border2.nntp.sjc.giganews.com!border1.nntp.sjc.giganews.com!nntp.giganews.com!local1.nntp.sjc.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 23 Jan 2004 23:52:31 -0600 Date: Sat, 24 Jan 2004 00:52:29 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Standard Ada Preprocessor (Was: why ada is so unpopular ?) References: <49cbf610.0401170627.79c3dfe5@posting.google.com> <400A9B48.3060100@noplace.com> <400BD4B5.6000307@noplace.com> <400BDB7C.40100@noplace.com> <400D2150.6000705@noplace.com> <400E72F9.8060501@noplace.com> <100upo7ln5e3k59@corp.supernews.com> <401118FD.701@noplace.com> In-Reply-To: <401118FD.701@noplace.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.77.160 X-Trace: sv3-YN3F7VJ0esAz9nAt2sVQuoBTsiduvfiXWK8puyx4eHSxVdCbU2eC7PBbWPZ18Ai2Vy81MBccdUJcO8E!QA+CwDL7tIX2XvyF14kmbxf+UJULBax7PL9trsCTtPs5DEgaQwsUwiIma7pH8w== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:4756 Date: 2004-01-24T00:52:29-05:00 List-Id: Marin David Condic wrote: > Perhaps a pragma that took some constant string and compared it to a > string literal and compiled the associated code only if equal would be > sufficient. I could build my "package Configuration" and have something > like > > pragma If_Equal (Configuration.OS => "TOPS 10", > ) ; > > It would be a cheap fix that minimizes the impact to any existing > packages or code and only requires compile-time interpretation of a > pragma - something compilers already do. Today you can write code that says: if Configuration.OS = "TOPS 10" then else end if; And your compiler should eliminate the code not executed if Configuration.OS is a static string constant. That is available now. What about declarations? Then you have two choices. The first is variant parts: type Foo(Choice: Boolean) is record case Choice is when True => Tops_10_Component: Float; when False => ... end case; end record; Or you can do: if Configuration.OS = "TOPS 10" then declare Tops_10_Only: Integer := ...; begin end; else declare Some_Other_Declaration: Some_Record_Type; begin end; end if; Also you can make a static Boolean constant: Tops_10: constant Boolean := Configuration.OS = TOPS 10"; If you want or need to, I usually do. Oh, one other neat trick. Look at Foo above. When creating all those objects of type Foo, you don't want to have to remember to specify the correct constraint. So just say: subtype Foob is Foo(Tops_10); If you forget and declare an object of type Foo, the compiler will tell you. (Unless of course you give it an initial value, but then you don't really have a bug anyway, since the value has the right discriminant.) If you are generating decent floating point code for x86 processors right now you can end up with a LARGE enumeration type and case statements. (Actually, combining the cases so the right one is available on each system is a non-trivial exercise. And once I get it working, I often leave the intended static constants as variables and set them at install-time or run-time. I need that to make testing survivable, so why not let people use it that way. ;-) So right now, these features are a usable part of the language. Not heavily used, but they can be. Which is why I think that "fixing" System and explaining why would be a big help. -- Robert I. Eachus "The war on terror is a different kind of war, waged capture by capture, cell by cell, and victory by victory. Our security is assured by our perseverance and by our sure belief in the success of liberty." -- George W. Bush