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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2308afbbe4ecec0b X-Google-Attributes: gid103376,public From: "David C. Hoos, Sr." Subject: Re: Subverting 'Access for Sub-programs Date: 1999/08/03 Message-ID: <7o7nhm$8oq@hobbes.crc.com>#1/1 X-Deja-AN: 508544874 References: <37A71EF1.2201@dera.gov.uk> Organization: Coleman Research Corporation X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 Newsgroups: comp.lang.ada Date: 1999-08-03T00:00:00+00:00 List-Id: Anton Gibbs wrote in message <37A71EF1.2201@dera.gov.uk>... >Dear Ada Community, > >Can someone please advise me on the best way to subvert the language >rules that prevent the use of 'Access on a locally declared procedure ? > >For normal objects it is possible to use 'Unchecked_Access but for >sub-programs this is not allowed. > >"Why does this idiot want to do this ?" I hear you ask. > >Well it seemed reasonable enough to me within a wider application, the >essence of which I have distilled into a few lines below. > The real problem is that the compiler cannnot know that procedure Main will have a lifetime as long as the entire program -- for there is nothing that says (at _compile_ time) that procedure Main is the _Main_ procedure. Since the subprogram to which you wish to provide access is nested within this procedure, its lifetime cannot be guaranteed _at compile time_ to exceed the lifetime of the subprogram(s) to which the access is passed. The solution is simply to declare the procedure Print_If_Even at library level -- either in a library-level package, or as a standalone library procedure. So... no subversion is necessary - just adhere as described, and you'll be fine.