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-Thread: 103376,400766bdbcd86f7c X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!nntp.giganews.com.MISMATCH!border1.nntp.dca.giganews.com!nntp.giganews.com!local1.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 17 Feb 2005 16:05:08 -0600 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <1108139611.709714.36170@o13g2000cwo.googlegroups.com> <2IcPd.6268$mG6.1474@newsread1.news.pas.earthlink.net> <1108372232.436036.318690@g14g2000cwa.googlegroups.com> <1108456053.837461.20340@f14g2000cwb.googlegroups.com> Subject: Re: This can't be done in Ada...or? Date: Thu, 17 Feb 2005 16:06:51 -0600 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-D0DOON8gti5rTQiC7REViflyn/Xj7tyfKHskcCX2kZHZe4FYVNzB1hcijP6XF+kR4Sm0cYpXNlO8t6T!QjXREmYJKzVAK5Jl2paF+rlxTFXvzN5QiXMJ828pMthKiabGq7r5cifF9VZHUhExjkf6WA2DHmmP X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.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.3.31 Xref: g2news1.google.com comp.lang.ada:8391 Date: 2005-02-17T16:06:51-06:00 List-Id: "Mark Lorenzen" wrote in message news:m3wttaciqw.fsf@0x53586c67.boanxx18.adsl-dhcp.tele.dk... > "Per Lindquist" writes: ... > > Will your solution cause overhead for each subprogram call? > > A compile-time instantiation of a package has nothing to do with > run-time efficiency. You can also define a new type in a subprogram, > which doesn't affect run-time efficiency either. That's sometimes true, but never on a compiler that code shared generics by default (like Janus/Ada). And even on compilers that treat generics as macros, it depends on the elaboration overhead. So it is a mistake to give that as a general rule. Similarly, a type declared in a subprogram might or might not have run-time overhead (it depends on what the elaboration of the type does - if it depends on a parameter, for instance, there almost certainly is some overhead). Not having the code for the generic in question (I couldn't find any easy way to see it on the PragmaARC site, and I didn't want to download the whole thing), I can't say what overhead it has. Clearly there is some size overhead, but that might not be much more than the size overhead of the explicit constants. Personally, I'd stick with the constants, because they can be tailored to disambiguate overloaded subprograms, and there is no possibility of overhead. But YMMV. Randy Brukardt. P.S. I don't find the "if" statements surrounding the tracing particularly "yucky". Unless your system is rather small, you'll need a way to control what is traced, and that can be combined into the if statement with no overhead when the traces are all off. One way is to use an extra constant: if (not Tracing.No_Logging) and then Tracing.Log_This (Where => ...) then Tracing.Log_Item (Where => ..., Item => "This is a log entry."); end if; We use variations on this in the Janus/Ada compiler, the AdaIC web server, the Trash Finder spam filter, and other tools. (Claw doesn't have any built-in tracing; it's too intrusive.) If you only need a variable to control tracing, you can change that to a constant to get rid of all of the overhead and use if statements with a single item: if Tracing.Log_Me then ... This solution requires a bit more version control (which is outside of Ada, of course), but it isn't bad. RLB