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, MSGID_RANDY 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: Robert Dewar Subject: Re: Subverting 'Access for Sub-programs Date: 1999/08/04 Message-ID: <7o8a11$ihv$1@nnrp1.deja.com>#1/1 X-Deja-AN: 508605415 References: <37A71EF1.2201@dera.gov.uk> X-Http-Proxy: 1.0 x35.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Wed Aug 04 02:54:28 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-08-04T00:00:00+00:00 List-Id: In article <37A71EF1.2201@dera.gov.uk>, 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 ? > For normal objects it is possible to use 'Unchecked_Access but > for sub-programs this is not allowed. The problem is that the equivalent of Unchecked_Access for subprograms is not at all easy to implement if you are using displays. The restrictions in the language regarding access to nested procedures are indeed semantically unnecessary. This was one of the few places where the design of the language was quite conciously compromised because of the strong representations from implementors (notably Alsys [Aonix], and RR) who used displays and argued that anything that would make the use of displays tricky was unacceptable. The design process was certainly in the business of taking vendor input into consideration (we all recognized that a marvelous language that people could not implement was not desirable :-) If you use static links, then it is indeed easy to implement both the safe versions proposed by the mapping team, and/or a version of unchecked_access that works for subprograms. Since GNAT uses static links, it is indeed easy to implement, and GNAT has an implementation defined attribute Unrestricted_Access that may indeed be applied to subprograms to obtain the effect you want. This is of course unsafe, in the sense that you can have (and use!) dangling subprogram pointers, so user beware! Robert Dewar Ada Core Technologies P.S. We have found Unrestricted_Access to be vital for implementing some of our run time and library packages (see for example the implementation of GNAT.Spitbol.Patterns in g-spipat.ads/adb files) Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.