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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.125.72 with SMTP id x8mr5021508qar.5.1380049566701; Tue, 24 Sep 2013 12:06:06 -0700 (PDT) X-Received: by 10.182.117.138 with SMTP id ke10mr6059obb.42.1380049566659; Tue, 24 Sep 2013 12:06:06 -0700 (PDT) Path: border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!d5no1777932qap.0!news-out.google.com!9ni111qaf.0!nntp.google.com!d5no1777930qap.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 24 Sep 2013 12:06:06 -0700 (PDT) In-Reply-To: <58149dd9-990d-415c-a121-bc7a1a69473c@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.37.243.76; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 NNTP-Posting-Host: 93.37.243.76 References: <58149dd9-990d-415c-a121-bc7a1a69473c@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Accessibility Levels and Library-Level Units From: mockturtle Injection-Date: Tue, 24 Sep 2013 19:06:06 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Original-Bytes: 4088 Xref: number.nntp.dca.giganews.com comp.lang.ada:183444 Date: 2013-09-24T12:06:06-07:00 List-Id: I am not a language lawyer, so maybe someone will be able to confirm/contradict me. I think that the problem is that Test is "local to" (defined inside) Accessibility_Level_Test. The problem is that you could have a "perverted" procedure Sub like this package body Bad is Old_Access : Proc_Type; procedure Sub(X : Proc_Type) is begin Old_Access := X; end Sub; procedure Boom is begin Old_Access("Boom"); end Boom; end Bad; Now, if your code was legal you could call Accessibility_Level_Test; Bad.Boom; and the latter would use the access to (non-existing) Test saved by Sub, causing... a boom. >From your post I understand that Accessibility_Level_Test; is the "main" program, but I am afraid that this does not count, but maybe a LL would be able to explain this better. Hope this help Riccardo On Tuesday, September 24, 2013 8:36:43 PM UTC+2, Eryndlia Mavourneen wrote: > I have a package that defines a single procedure access type: > > > > 1. package Accessibility_Level_Def is > > 2. pragma Pure; > > 3. type Proc_Type is access procedure (An_Str : String); > > 4. end Accessibility_Level_Def; > > > > I have a main program which references it (and another package): > > > > 1. with Ada.Text_IO; use Ada.Text_IO; > > 2. with Accessibility_Level_Def; use Accessibility_Level_Def; > > 3. with Accessibility_Level_Implementation; use Accessibility_Level_Implementation; > > 4. procedure Accessibility_Level_Test is > > 5. procedure Test (Text : String); > > 6. procedure Test (Text : String) is > > 7. begin > > 8. Put_Line ("in Test"); > > 9. end Test; > > 10. > > 11. The_Proc : Proc_Type; > > 12. begin > > 13. The_Proc := Test'Access; > > 14. Sub (Proc => The_Proc); > > 15. end Accessibility_Level_Test; > > > > Gnat 2012 (on Ubuntu) gives the error on line 13: > > > > "Subprogram must not be deeper than access type." > > > > I thought I understood accessibility levels, at least, I understood the examples I have found. Yet, this example appears to not have the same issues: > > > > 1) All the units -- packages and procedure -- are at library level. > > 2) The procedure is statically defined and is not going to be > > deallocated until the program exits. > > > > This is very frustrating and would seem to preclude the definition of a procedural access type in a separate definitions package. The Implementation package (defining procedure Sub but not shown) compiles nicely, btw. > > > > Is this a problem with Gnat? If not, how can I do what I want to do? The attribute Unchecked_Access is not available for subprogram access types. > > > > -- Eryndlia (KK1T)