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, T_FILL_THIS_FORM_SHORT 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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Running a preprocessor from GPS? Date: Sat, 1 Aug 2015 11:59:58 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <91f88d79-197c-419f-84a8-908e05967a2c@googlegroups.com> <135c2b00-d13c-4f5d-a586-8aca442d363b@googlegroups.com> <87380683vc.fsf@adaheads.sparre-andersen.dk> <347c6be9-c918-4bc0-9494-c93cd6740def@googlegroups.com> <4cb32c40-f659-490d-bbb6-73585fc069e8@googlegroups.com> <7e653a88-e690-431a-9df9-3fc691466e08@googlegroups.com> <25e8deb9-a967-4856-97cb-4257e1ba7fa4@googlegroups.com> <84debe67-b26c-40c6-93ae-a2dec28f081b@googlegroups.com> <87a8ualvt2.fsf@jester.gateway.sonic.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Sat, 1 Aug 2015 18:58:25 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="ee44d3db9c41f5ad88d7e8e8f0268f05"; logging-data="22614"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nyvN3MoeFaJ3i8tL6x60gM+PV0GDxsBI=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 In-Reply-To: <87a8ualvt2.fsf@jester.gateway.sonic.net> Cancel-Lock: sha1:hg4wJ9DsYu7Yokc39LaGDRnjtcY= X-Enigmail-Draft-Status: N1110 Xref: news.eternal-september.org comp.lang.ada:27305 Date: 2015-08-01T11:59:58-07:00 List-Id: On 08/01/2015 11:15 AM, Paul Rubin wrote: > > Is there a good place to read about this? I had the impression that > package initialization runs unconditionally. EGarrulo was asking how to > get it to run only in response to a runtime request that might never > happen. It depends on what you mean by "initialize". Elaboration of a library pkg occurs at start up unconditionally. There's no requirement that a pkg be a library pkg, so that could be a way to get pkg elaboration to happen later, though it's not common. Initialization of an object happens when the object is created. For an object created by an object declaration, that happens when the declaration is elaborated: package body P is State : Integer := Integer'First; If the initialization is complex, it can be done in the executable part of the pkg body when that is elaborated: package body P is State : Integer; ... begin -- complex code that assigns a value to State end P; If initializing State requires information that the pkg can't get by itself, then initialization can be performed by an operation called by a client: package P is State : Integer; Initialized : Boolean := False; procedure Initialize (Value : in Integer) is begin if Initialized then raise Already_Initialized; end if; State := Value; Initialized := True; end Initialize; procedure Op is begin if not Initialized then raise Not_Initialized; end if; ... end Op; This latter case delays initialization to response to a run-time request that might never happen. Allocation of storage for State still happens during elaboration of P. Delaying allocation of storage as well is straightforward and left as an exercise for the reader. -- Jeff Carter "I don't know why I ever come in here. The flies get the best of everything." Never Give a Sucker an Even Break 102