comp.lang.ada
 help / color / mirror / Atom feed
From: Anton Gibbs <agibbs@dera.gov.uk>
Subject: Procedure Access Values
Date: 1998/02/12
Date: 1998-02-12T00:00:00+00:00	[thread overview]
Message-ID: <34E2B8C3.4D61@dera.gov.uk> (raw)


Please can someone help me to understand a problem I have run into
using procedure access values.

We have a system that uses call-back procedures in a manner
similar to the following:-

package Notifiers is
   type Callback_Type is access procedure;
   procedure Notify_Me_When_Event_Occurs( Callback : in Callback_Type );
end Notifiers;

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 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;

Now we get the following compilation error on the line marked *:-

    "access type must not be outside generic body"

I realise that in Ada95 there are rules governing access values which
are intended to prevent dangling references. What baffles me is that
if the declaration of procedure Event_Handler is moved to the package
specification, then the compiler accepts the 'Access without complaint.

How can the legality of taking an access value depend on whether or
not the procedure is local ?

If anyone can shed any light on this I would be most grateful.

Thank you.

Anton Gibbs
Eurocontrol




             reply	other threads:[~1998-02-12  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-02-12  0:00 Anton Gibbs [this message]
1998-02-13  0:00 ` Procedure Access Values John English
  -- strict thread matches above, loose matches on Subject: below --
1998-02-03  0:00 Anton Gibbs
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox