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!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Elaboration Question Date: Fri, 02 Jan 2015 23:57:17 +0200 Organization: Tidorum Ltd Message-ID: References: <_3spw.995330$Fo3.305798@fx09.iad> <176076d0-ca97-46b5-8b6f-81e9289643c4@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 6kO1HhZqyh5vHrPGzA+WRwn19eiDcIzye+Jst26wb/2trAhrCS Cancel-Lock: sha1:FnAfBWlI7tyDeTjURu1hKlTng64= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:24320 Date: 2015-01-02T23:57:17+02:00 List-Id: On 15-01-02 17:11 , sbelmont700@gmail.com wrote: > On Friday, January 2, 2015 6:08:24 AM UTC-5, Mark Lorenzen wrote: >> >> What strategy would you use when writing a library in Ada, that is >> to be called from e.g. a program written in C? >> > > The onus is on the calling code to ensure elaboration happens > correctly. The best strategy to use from the library-side is to just > make sure all your code is Preelaborate (or Pure), and the problem > solves itself. This advice probably works in practice, but formally speaking, I cannot find a promise in the Ada RM (2012 version) that a Preelaborable library unit is free of elaboration code. RM 10.2.1(11/3) promises that all preelaborated library units are elaborated before any non-preelaborated library units, but formally, even the preelaborated units are still "elaborated" in some sense. Even the implementation advice the RM gives for preelaboration (10.2.1(12)) speaks of elaborations of the preelaborable units that "occur in distinct executions of the same program", which sounds very much like some elaboration code being executed at execution time. So to me it appears safest to ensure that the C main program calls the Ada elaboration and finalisation operations, as David Botton suggested, and then it is not necessary to follow the strong restrictions of Preelaborable or Pure units. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .