comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: How to get around "access type must not be outside generic unit"
Date: Mon, 18 Dec 2006 08:49:28 +0100
Date: 2006-12-18T08:49:28+01:00	[thread overview]
Message-ID: <e6h5me.3f.ln@hunter.axlog.fr> (raw)
In-Reply-To: <sa43b7dx4eb.fsf@margay.local>

Brian May a �crit :
>>>>>> "Pascal" == Pascal Obry <pascal@obry.net> writes:
> 
>     Pascal> Solution 2) Move access to generic spec
> 
> ...
> 
>     Pascal> begin Register ("Doit", Install_Access); end Usage;
> 
> How is this any different from using Install'Access?
> 
> I would have thought since Install was defined within the generic
> unit, Install'Access would be OK.
> 
> Or does Install'Access imply a temporary local variable?
It's all about the contract model. When you instantiate a generic, you 
are supposed to "see" the specification, but not the body. Hence, 
declarations in the specification "assume the best", i.e. anything is 
allowed, assuming that if certain constructs are illegal due to the 
properties of the actual parameters, the instantiation will be rejected.

Since you are not supposed to see the body, this is not possible for 
declarations in the body, hence the body "assumes the worst": anything 
that could be illegal *is* illegal. Therefore, moving the offending 
declaration from body to spec can solve the problem.

> Put another way, how can you create a dangling pointer with
> Install'Access but not Install_Access?
> 
Just instantiate that generic inside a procedure.
Install becomes a local function of that procedure, but you would keep a 
'access on it in a global structure. Taking the 'access in the 
specification is illegal, and (as explained above), the instantiation 
would be illegal.
-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  reply	other threads:[~2006-12-18  7:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-17 10:07 How to get around "access type must not be outside generic unit" Michael Erdmann
2006-12-17 12:45 ` Pascal Obry
2006-12-17 14:28   ` Michael Erdmann
2006-12-17 15:53     ` Pascal Obry
2006-12-17 20:49     ` Robert A Duff
2006-12-18  3:35   ` Brian May
2006-12-18  7:49     ` Jean-Pierre Rosen [this message]
2006-12-18 23:15       ` Brian May
2006-12-19  1:48         ` Randy Brukardt
2006-12-19  7:41         ` Jean-Pierre Rosen
2006-12-18 20:32     ` Michael Erdmann
2006-12-18 20:57       ` Randy Brukardt
2007-01-23 18:18 ` [Revisited] How to get around "access type must not be outside generic unit" (was: How to get around "access type must not be outside generic unit") Dmitry A. Kazakov
2007-01-24  0:57   ` Randy Brukardt
2007-01-24 11:42     ` [Revisited] How to get around "access type must not be outside generic unit" Dmitry A. Kazakov
2007-01-24 11:58       ` Ludovic Brenta
2007-01-24 13:46         ` Dmitry A. Kazakov
2007-01-24 20:50       ` Randy Brukardt
2007-01-25 11:07         ` Dmitry A. Kazakov
replies disabled

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