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!news4.google.com!news.glorb.com!newscon02.news.prodigy.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: This can't be done in Ada...or? Date: 15 Feb 2005 08:41:26 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: 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> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1108474887 1306 69.38.147.31 (15 Feb 2005 13:41:27 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 15 Feb 2005 13:41:27 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:8335 Date: 2005-02-15T08:41:26-05:00 List-Id: Jacob Sparre Andersen writes: > Mark Lorenzen wrote: > > "Per Lindquist" writes: > > > > One of our target environments is a time-critical real-time > > > system. We are worried about the execution overhead implied by a > > > package instantiation (or any 'new' statement) in every subprogram > > > in the system. > > > > > > Will your solution cause overhead for each subprogram call? Probably. > > 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. > > Aren't the compilers (theoretically) allowed to delay the > instantiation of the packgage until run-time? No, instantiation is a compile-time concept. I'm not sure what it would mean to delay it until run time. The issue here is the cost of running the elaboration code of the instance. Theoretically, the compiler could optimize it away in this case, but I don't think any Ada compilers are that smart. The only way to know for sure is to try it. This Reflection package has a bunch of string manipulation code, and if you instantiate it in a procedure, it will happen every time that procedure is called (unless the compiler is smarter than I think it is). This could indeed be very costly. - Bob