From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f7d6c5172a1d41b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!news.glorb.com!proxad.net!news.in2p3.fr!in2p3.fr!oleane.net!oleane!hunter.axlog.fr!nobody From: Jean-Pierre Rosen Newsgroups: comp.lang.ada Subject: Re: How to get around "access type must not be outside generic unit" Date: Mon, 18 Dec 2006 08:49:28 +0100 Organization: Adalog Message-ID: References: <45853BDC.5000902@obry.net> NNTP-Posting-Host: mailhost.axlog.fr Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Trace: s1.news.oleane.net 1166428863 32117 195.25.228.57 (18 Dec 2006 08:01:03 GMT) X-Complaints-To: abuse@oleane.net NNTP-Posting-Date: Mon, 18 Dec 2006 08:01:03 +0000 (UTC) User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:7940 Date: 2006-12-18T08:49:28+01:00 List-Id: Brian May a �crit : >>>>>> "Pascal" == Pascal Obry 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