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 21:55:13 PST Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!chcgil2-snh1.gtei.net!news.bbnplanet.com!nycmny1-snf1.gtei.net!news.gtei.net!colt.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Preprocessor functionality equivalent ideas needed Date: 12 Dec 2003 05:52:32 +0000 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1071208511 6168 62.49.19.209 (12 Dec 2003 05:55:11 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Fri, 12 Dec 2003 05:55:11 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: archiver1.google.com comp.lang.ada:3407 Date: 2003-12-12T05:52:32+00:00 List-Id: Georg Bauhaus writes: > There are two more ways I know of, one uses generics for listing > the configuration-specific things that your program needs. The other > uses tagged types, that is O-O types. Again for OSs, > > generic > type OS is private; > > with function available_disk_space (op_sys: OS) return Natural; > -- free blocks > > package System_Dependent is > procedure Installation_Setup; > procedure Unpack; > end System_Dependent; > > If you now write > > with BSD; > package Everywhere_Working_Installation is > new Specifics (available_disk_space => BSD.free_blocks_count); > > you can use the procedures in package Everywhere_Working_Installation > in your program. A technique we've found handy is an extension of the "generic signature package" idea, for use when your code won't be written in a generic: generic with procedure Actual_P (I : Integer); with function Actual_Q return Boolean; package Signature is procedure P (I : Integer) renames Actual_P; function Q return Boolean renames Actual_Q; end Signature; That way you don't have to use the names P, Q in the actual package (indeed, the actual subprograms could come from more than one package). -- Simon Wright 100% Ada, no bugs.