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,b7ecd0508d245308 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: Subprogram access types and generic packages Date: 1997/03/20 Message-ID: #1/1 X-Deja-AN: 226987352 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-03-20T00:00:00+00:00 List-Id: Greg Bond (bond@ee.ubc.ca) wrote: : I'm trying to write a generic package that will register an access type : of one of its internal subprograms with an external subprogram when : instantiated. I get the error message: : pkg.adb:12:14: access type must not be outside generic body : Why not? Because the RM says so ;-). RM95 3.10.2(32) says: P'Access ... If the subprogram denoted by P is declared within a generic body, S [the access-to-subp type] shall be declared within the generic body. The annotated RM goes on to say: ... This rule is partly to prevent contract model problems with respect to accessibility rules, and partly to ease shared-generic-body implementations, in which a subprogram declared in an instance needs to have a different calling convention from other subprograms with the same profile. The way to avoid the problem is to move the declaration of the subprogram up into the private part of the generic spec. This gives the shared-generic implementation the chance to create a unique wrapper at each instantiation, so a simple address (rather than an address + a pointer to an "instance descriptor) is sufficient to call the subprogram. If none of the above makes sense, then revert to my first explanation (the RM says so) or talk to Randy Brukardt or other compiler implementor whose compiler uses "universal" generic sharing. : * Greg Bond * Dept. of Electrical and Computer Eng. : * email: bond@ee.ubc.ca * Univ. of British Columbia : * voice: (604) 822 0899 * 2356 Main Mall : * fax: (604) 822 5949 * Vancouver, BC : * web: http://www.ee.ubc.ca/~bond * Canada, V6T 1Z4 -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA