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,d3037f71d9d26da1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-11 09:49:22 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!newsfeed2.easynews.com!easynews.com!easynews!newsfeed.news2me.com!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Preprocessor functionality equivalent ideas needed References: <3FD8726E.1000205@noplace.com> In-Reply-To: <3FD8726E.1000205@noplace.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 11 Dec 2003 17:49:22 GMT NNTP-Posting-Host: 63.184.8.229 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1071164962 63.184.8.229 (Thu, 11 Dec 2003 09:49:22 PST) NNTP-Posting-Date: Thu, 11 Dec 2003 09:49:22 PST Xref: archiver1.google.com comp.lang.ada:3392 Date: 2003-12-11T17:49:22+00:00 List-Id: Marin David Condic wrote: > While I agree with the general concept of separate bodies for separate > implementation-specific modules, I have occasionally run into situations > where it would have been nice if I had a compiler directive of some sort > to go one way or another depending on some condition. This is especially > true where I might need to keep code portable between two different > compilers. Also its a big problem when what needs to be different is in > the *specification* of something. (Yes, I know, "One more layer of > indirection...." can go fix it - but why should it be so hard?) There are several ways to deal with needing multiple versions of the spec. Sometimes you can use functions instead of constants: package P is -- Version X Num_Processors : constant := 4; end P; package P is -- Version Y Num_Processors : constant := 256; end P; becomes package P is function Num_Processors return Positive; end P; Functions are sometimes not acceptable because the value needs to be static. Sometimes you can have multiple versions with different names, and use renaming to select the appropriate one: package P_X is Num_Processors : constant := 4; Directory_Separator : constant Character := '\'; end P_X: package P_Y is Num_Processors : constant := 256; Directory_Separator : constant Character := '/'; end P_Y; with P_X; package P renames P_X; Now the values in P are static. And while another layer of information hiding may be harder in the short run, it's almost always easier in the long run. -- Jeff Carter "Sir Lancelot saves Sir Gallahad from almost certain temptation." Monty Python & the Holy Grail 69