comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Marc Bourguet <bourguet@my-deja.com>
Subject: Re: A question to the "access-type lifetime rule"
Date: 2000/04/03
Date: 2000-04-03T00:00:00+00:00	[thread overview]
Message-ID: <8ca7pr$vb7$1@nnrp1.deja.com> (raw)
In-Reply-To: 38E89AB9.7D33E88C@hamilton.physik.uni-konstanz.de

In article <38E89AB9.7D33E88C@hamilton.physik.uni-konstanz.de>,
bernd.rinn@uni-konstanz.de wrote:

> I want to write an numerical integration function, that is defined
> in a separate package as
>
> type Integrand_Type is access function ( X : Long_Float ) return
> Long_Float;
> function Integrate(Integrand : Integrand_Type; Lower_Bound,
Upper_Bound
> : Long_Float) return Long_Float;
>
> Now I would like to call this from a main procedure and pass an access
> attribute of a nested function of the main procedure as `Integrand'.
> Is there a way to reach this? (Unchecked_Access is not an allowed
> attribute for subprograms and I do not want to generate a package of
> it's own for the integrand function.)

1) Make the integrate function a generic function whose parameter
is the integrand. Then instanciate the integrate function where
you want to use it.

2) Use gnat which has an attribute allowing to bypass the rule. But
be warned not to store the access value gotten longer than the
subprogram lives.

-- Jean-Marc


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




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

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-04-03  0:00 A question to the "access-type lifetime rule" Bernd Rinn
2000-04-03  0:00 ` David
2000-04-03  0:00 ` Gautier
2000-04-03  0:00 ` Robert Dewar
2000-04-03  0:00 ` Jean-Marc Bourguet [this message]
2000-04-04  0:00 ` John English
replies disabled

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