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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Why can't objects be static in Ada? Date: Tue, 16 Apr 2019 17:19:52 +0100 Organization: A noiseless patient Spider Message-ID: References: <1127d366-d36c-4abf-8590-4b8c0e2b5446@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="1f66f0f0c4848c0e1c8dbb8a437f0731"; logging-data="27917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ePiJxhwr54zWMSCG972D1dW8MeEkxhRo=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (darwin) Cancel-Lock: sha1:EyU6C3fQhvr3cnhZNau+RB3v1vY= sha1:3u2rT02mb12Mg91fosTR8sR0LeQ= Xref: reader01.eternal-september.org comp.lang.ada:56137 Date: 2019-04-16T17:19:52+01:00 List-Id: Mark Lorenzen writes: > On Tuesday, April 16, 2019 at 3:40:45 AM UTC+2, Randy Brukardt wrote: >> > >> > package Static is >> > pragma Preelaborate; >> >> I view this as self-inflicted, because there's no little value to >> pragma Preelaborate. As I previously noted, compilers will almost >> always generate the best possible elaboration code whether or not >> that pragma is applied. And regardless of C.4, not all preelaborated >> code can be done before load time, so it isn't providing a benefit in >> forcing that sort of code, either. >> >> It's one of the ideas where Ada tried to accomplish something, but >> didn't quite succeed. Pure is like that as well, but at least it >> provides some benefits for Annex E code. Preelaborate doesn't even do >> that. > > How can it be ensured that a library written in Ada does not require > any elaboration. Pragma Pure? I think that such libraries are "nice" > but pragma Pure is too restrictive for that purpose. In such cases it > would be good, if e.g. the OP's problem could be solved at compile > time without any elaboration. The GNAT pragma No_Elaboration_Code_All will do the trick (or fail if it can't be done).