comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Elaboration Question
Date: Fri, 02 Jan 2015 23:57:17 +0200
Date: 2015-01-02T23:57:17+02:00	[thread overview]
Message-ID: <cgoihuF7sr6U1@mid.individual.net> (raw)
In-Reply-To: <b99580ed-aff8-41f2-a125-35a695827d85@googlegroups.com>

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
       .      @       .

  reply	other threads:[~2015-01-02 21:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-02  3:27 Elaboration Question Hubert
2015-01-02  7:56 ` Simon Wright
2015-01-02 22:16   ` Randy Brukardt
2015-01-02 14:49 ` Brad Moore
2015-01-02 11:08   ` Mark Lorenzen
2015-01-02 13:35     ` David Botton
2015-01-02 15:11     ` sbelmont700
2015-01-02 21:57       ` Niklas Holsti [this message]
2015-01-06  2:33         ` Randy Brukardt
2015-01-06  8:17           ` Niklas Holsti
2015-01-06 20:06             ` Randy Brukardt
2015-01-03  9:45 ` Jean François Martinez
2015-01-03  9:50   ` Hubert
2015-01-03 18:43     ` Jean François Martinez
2015-01-04  1:57       ` Hubert
2015-01-04 12:05       ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox