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,9c0dfd45a22e1cfa X-Google-Attributes: gid103376,public From: je@bton.ac.uk (John English) Subject: Re: Procedure Access Values Date: 1998/02/13 Message-ID: <6c2cds$2ej@saturn.brighton.ac.uk>#1/1 X-Deja-AN: 324891055 References: <34E2B8C3.4D61@dera.gov.uk> Organization: University of Brighton Newsgroups: comp.lang.ada Date: 1998-02-13T00:00:00+00:00 List-Id: Anton Gibbs (agibbs@dera.gov.uk) wrote: : This all works fine. The problem we have run into occurs when we : convert package P into a generic. ie:- : generic package P is : procedure Start; : end P; : with Notifiers; : package body P is : procedure Event_Handler is ...; : : procedure Start is : begin : Notifiers.Notify_Me_When_Event_Occurs( Event_Handler'Access );--* : end Start; : : end P; This will be a problem if you instantiate your generic inside a procedure. The elaboration of the package body happens at the point of instantiation, i.e. one lexical level deeper than the level (library level) at which Notifiers.Event_Handler is declared. The solution is to instantiate the generic in a library level package, i.e. with P; package Q is package R is new P; -- the access value in R is at the same level as P end Q; with Q; procedure Main is -- use Q.R here end Main; rather than: with P; procedure Main is package R is new P; -- R contains an access created at the wrong ... -- lexical level end Main; ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------