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!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Accessibility Levels and Library-Level Units Date: Tue, 24 Sep 2013 12:31:08 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: <58149dd9-990d-415c-a121-bc7a1a69473c@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 24 Sep 2013 19:31:10 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="5a64620cc83ca47629e9cd617d12fc26"; logging-data="20204"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WgPT6Wu8WsyKAsCgJ5PRKtd1xhzcI2L0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: <58149dd9-990d-415c-a121-bc7a1a69473c@googlegroups.com> Cancel-Lock: sha1:5B6B0ThxOkGVroRjn2EVCoLvgv0= Xref: news.eternal-september.org comp.lang.ada:17270 Date: 2013-09-24T12:31:08-07:00 List-Id: On 09/24/2013 11:36 AM, Eryndlia Mavourneen wrote: > > 1) All the units -- packages and procedure -- are at library level. > 2) The procedure is statically defined and is not going to be > deallocated until the program exits. > > This is very frustrating and would seem to preclude the definition of a > procedural access type in a separate definitions package. The Implementation > package (defining procedure Sub but not shown) compiles nicely, btw. > > Is this a problem with Gnat? If not, how can I do what I want to do? The > attribute Unchecked_Access is not available for subprogram access types. Your main-program procedure, while declared at the library level, is not necessarily at library level. This is because it is a subprogram, and its accessibility level is determined by where and when it is called. Although you know that it is only called by the environment task once, the compiler doesn't know that, and the language provides no way to tell the compiler that, probably because checking it is painful. The procedure could call itself recursively, or something else could with it and call it. In either case, the accessibility level of the procedure nested within it will not be library level. There are 2 ways to do what you want: declare the subprogram (whose access value will be assigned to the access object) in a library-level package, or use an anonymous access-to-subprogram parameter rather than a named access-to-subprogram type. -- Jeff Carter "He didn't get that nose from playing ping-pong." Never Give a Sucker an Even Break 110