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,355f90547d1b4b5 X-Google-Attributes: gid103376,public From: Samuel Mize Subject: Re: PRECOMPILATION Date: 1999/02/19 Message-ID: <7ajv1n$23v0@news1.newsguy.com>#1/1 X-Deja-AN: 446096801 References: <918556681.260459@dedale.pandemonium.fr> <36C0B5D4.DEF83A66@averstar.com> <7ahor8$otv@news1.newsguy.com> <7aickf$pb4$1@news-1.news.gte.net> Organization: ImagiNet Communications, Ltd. User-Agent: tin/pre-1.4-981002 ("Phobia") (UNIX) (AIX/3-2) Newsgroups: comp.lang.ada Date: 1999-02-19T00:00:00+00:00 List-Id: Rakesh Malhotra wrote: > Samuel Mize wrote: [about preprocessors forcing you to address portability issues throughout your code] > Would it be possible to give an Ada example of how you would do what you > have suggested in your message above ? i.e. what kind of things does > one put into the platform specific packages, does one not land up with > having to maintain many such packages versus just 1 file in the C case > etc ? Some code that highlights your explanation will help. I don't have an example handy. I assume there would be some useful tutorial or example material at www.adahome.com or the ACM SigAda web site. Here's a sketch. Suppose you want to use a system call to get the current time. As I recall, there are at least three different "standard" Unix OS calls to do this, each of which uses a different data structure. A given Unix box will provide at least one of these. And I assume Windows does something different. An Ada programmer would decide what representation of time is best in this program, and write a package that makes the system call, extracts time to the desired representation, and returns it. Thus, the entire program is insulated from the differences between systems, except inside one package. (That package being Ada.Calendar, in this example.) Now, a sterotypical C programmer believes that preprocessor directives are much more efficient than procedure calls. So he would use #ifdefs to select the right call and data structure. If he is really worried about performance, he'll put the #ifdefs in-line in the code. If he is a little less worried about performance, he'll put the #ifdefs into a macro that makes the right call and puts the current time into a global data structure. The Ada programmer will trust the compiler to optimize the code, instead of trying to do so by hand. This is aided by pragma Inline, which tells the compiler it may treat a procedure definition as if it were a preprocessor macro, if convenient. I hope this is enough to give you an idea. Look for tutorials and books on portability, and on design encapsulation. The book "Ada Quality and Style" has a section on portability, you may find that useful. AQ&S is available electronically for free, you can find it via adahome, one specific URL is: http://wuarchive.wustl.edu/languages/ada/ajpo/docs/style-guide/ 95style/html/cover.html Best, Sam Mize -- Samuel Mize -- smize@imagin.net (home email) -- Team Ada Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam