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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ec2b9b815bd3b0bd X-Google-Attributes: gid103376,public From: Laurent Pautet Subject: Re: Conditional Code in Ada 95? Date: 1998/08/28 Message-ID: #1/1 X-Deja-AN: 385609425 Content-Transfer-Encoding: 8bit References: <35DDFB42.1311@boeing.com> <2$$CdIjQwTPX@nedcu4> <6rrtuf$cqg@top.mitre.org> <6s0fcl$3gj$1@platane.wanadoo.fr> Content-Type: text/plain; charset=iso-8859-1 Organization: ENST, France Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-08-28T00:00:00+00:00 List-Id: "Jean-Pierre Rosen" writes: > > However, there is something that's damn close to it: > > with Hardware_Specific_1; > package Hardware_Specific renames Hardware_Specific_1; > > and then use package Hardware_Specific all over the place. If you change > hardware, there is one line to change in the whole program. Well, that's not so easy. It could be quite difficult to maintain. It could be very error-prone as well. For a package with constant declarations, I think it is better to generate it automatically (during configuration). Concerning the code, for a package (which is a logical unit you don't want to reorganize), you have to split it into a platform independent part and N platform dependent parts. It's even worth when platforms are really different (Windows vs Unix). A piece of code could be identical on any Unix platform (so why would you duplicate it?) but different on Windows. If you do this for several units, then it's a lot of work and a lot of errors. The trick you mentioned is used in the GNAT run-time. Robert can tell us whether it is easy to maintain or not. I should admit that it won't be easier to maintain it using conditional code. But if you look closely to some low level parts of GNAT, there are written in C with conditional code (OS_Lib for instance). So, both mechanisms are used. I think there is no general solution and you should be allowed to use package renaming, automatic code generation or conditional code. Incidentally, I guess each compilor vendor has its own tool to provide conditional code but as it is not standardized, it is not portable. -- -- Laurent