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: Brian Rogoff Subject: Re: Subverting 'Access for Sub-programs Date: 1999/08/03 Message-ID: #1/1 X-Deja-AN: 508640324 References: <37A71EF1.2201@dera.gov.uk> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 933740095 228 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-08-03T00:00:00+00:00 List-Id: On Tue, 3 Aug 1999, Anton Gibbs wrote: > 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 ? I'm looking forward to a week where this question is asked every day :-). > 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. Not at all. Any idiot who has ever used Pascal can do this, as can any idiotic user of a functional programming language, though, to be fair, the FPers pay for that in general with garbage collection. If you use GNAT, Unrestricted_Access does what you want. You have suggested generic contortions, others suggest hauling the offending function up to library level, and then offer excuses as to why Ada has this big wart, sometimes even justifying the wart by arguing that these contortions are a good idea. Robert Dewar explains the "why" of the access rules in his post, and the reason for the fondness for displays over static links goes back to the requirements for Ada 83. Another workaround is to use tagged types, but since you can't extend them locally either it isn't often too helpful. The consolation here is that neither C++ nor Java even have nested functions. -- Brian