comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Using a procedure as a parameter (Gnat)
Date: 1996/03/27
Date: 1996-03-27T00:00:00+00:00	[thread overview]
Message-ID: <DowMnK.K6F@world.std.com> (raw)
In-Reply-To: 4ja0da$442@newsflash.concordia.ca

In article <4ja0da$442@newsflash.concordia.ca>,
Chris O'Regan <chris@ECE.Concordia.CA> wrote:
>ack.adb:11:35: subprogram must not be deeper than access type

Deeper means more deeply nested within subprograms (packages don't
count).  In your case, you can easily move the procedure into a package,
since it doesn't reference any local variables in the next-outer
procedure.  So put P in a library package, and all will be well.

Sometimes, the procedure you want to pass wants to reference variables
in the next-outer procedure.  In that case, you can use GNAT's
'Unrestricted_Access.  But beware: (1) it's not a standard feature, and
(2) it can cause dangling pointers if you're not careful.  A better
alternative might be to use a generic formal subprogram.

- Bob




      reply	other threads:[~1996-03-27  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-26  0:00 Using a procedure as a parameter (Gnat) Chris O'Regan
1996-03-27  0:00 ` Robert A Duff [this message]
replies disabled

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