comp.lang.ada
 help / color / mirror / Atom feed
From: Jeff Carter <jrcarter001@my-deja.com>
Subject: Re: Instantiating a generic formal procedure with an access procedure value
Date: 2000/01/04
Date: 2000-01-04T00:00:00+00:00	[thread overview]
Message-ID: <84rnbm$8jo$1@nnrp1.deja.com> (raw)
In-Reply-To: 3870E3F1.906FDFF4@averstar.com

In article <3870E3F1.906FDFF4@averstar.com>,
  Tucker Taft <stt@averstar.com> wrote:
> Jeff Carter wrote:
> >    procedure Op (Item : in out Handle; Item : in Integer);
>
> I presume you mean ------------------->>> Element : in Integer <<<

Yes, thanks for pointing out that error.

> >       procedure Iterate (Action : in Action_Ptr) is
> >          procedure Local is new S_U.Iterate (Action => ???);
> >          -- What do I use here?
>
> Action.all is the name of a subprogram.  It happens to have
> convention "protected" but that is irrelevant to a generic
> formal subprogram, which should accept subprograms of any
> convention.

I don't see why it should have convention "protected", since Action_Ptr
is defined in the spec of package S and the actual procedure pointed to
by a call to Iterate must be declared at the library level. However,
that should be irrelevant.

> As usual, without the actual source and the actual error message,
> it will be hard to determine where the real problem lies.
> But it may be a compiler bug...
>
> Action.all is the correct thing to use as the actual for a generic
> formal subprogram.

That's what I thought.

Using

type Handle is new Integer;

for the full definition of S_U.Handle (which is irrelevant but
necessary for compilation), and a body of S with Action.all:

package body S is
   protected body Handle is
      procedure Op (Element : in Integer) is
      begin -- Op
         S_U.Op (Item => Data, Element => Element);
      end Op;

      procedure Iterate (Action : in Action_Ptr) is
         procedure Local is new S_U.Iterate (Action => Action.all);
      begin -- Iterate
         Local (Over => Data);
      end Iterate;
   end Handle;
end S;

I get these messages from GNAT 3.11p

s.adb:9:10: instantiation abandoned
s.adb:9:63: missing argument for parameter "Element"
s.adb:11:10: "Local" is undefined


I realize that 3.12p is current, but I lack the bandwidth to download
it right now. It may be a compiler error, and may be corrected in 3.12p
or in compilers from other vendors, but I'd like confirmation that
other compilers do accept this.

Thanks for taking the time to think about this.
--
Jeff Carter
"Now go away or I shall taunt you a second time."
-- Monty Python and the Holy Grail


Sent via Deja.com http://www.deja.com/
Before you buy.




  reply	other threads:[~2000-01-04  0:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-31  0:00 Instantiating a generic formal procedure with an access procedure value Jeff Carter
2000-01-03  0:00 ` Tucker Taft
2000-01-04  0:00   ` Jeff Carter [this message]
2000-01-04  0:00     ` Tucker Taft
2000-01-05  0:00       ` Jeff Carter
2000-01-05  0:00         ` Ed Falis
2000-01-12  0:00         ` Jeff Carter
2000-01-12  0:00           ` Simon Wright
2000-01-13  0:00             ` Jeff Carter
2000-01-13  0:00               ` Simon Wright
2000-01-13  0:00               ` Tucker Taft
2000-01-14  0:00                 ` Jeff Carter
replies disabled

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