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,73175d2d01a1b1dd X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.46.193 with SMTP id x1mr845275pbm.7.1316987637208; Sun, 25 Sep 2011 14:53:57 -0700 (PDT) Path: lh7ni4865pbb.0!nntp.google.com!news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: subprogram must not be deeper than access type Date: Sun, 25 Sep 2011 17:53:56 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1316987636 20646 192.74.137.71 (25 Sep 2011 21:53:56 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 25 Sep 2011 21:53:56 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:IB6OEdZlh1H/VVHitaVXshxOd9s= Xref: news1.google.com comp.lang.ada:18122 Content-Type: text/plain; charset=us-ascii Date: 2011-09-25T17:53:56-04:00 List-Id: Jeffrey Carter writes: > The problem is that there is nothing special about the main-program > procedure. Specifically, it could be withed and called from something > else, or call itself recursively. In either case, its declarative > region, with its declaration of the function, would be nested deeper > than the declaration of the access type. Since this is a compile-time > check, it rejects anything that might be deeper, even when it never is. Right. Also, when the main procedure returns, that's not the end of the program. Library-level tasks can keep running for a long time after that. It's really annoying that in Ada you can't write a small example program (with a single compilation unit in a single file) that has multiple library-level things. If I ran the circus, there would be no library subprograms. The main procedure would be declared inside a library PACKAGE. > The basic rule with named access-to-subprogram types is that the actual > subprogram must be declared in a library-level package. Right. Just to clarify: library-level means not nested in any procedures, functions, or tasks. If the (named) access type is declared at library level, then for P'Access, P must be declared at library level. Nesting within any number of packages doesn't count, for accessibility levels. Anonymous access types work differently. GNAT has P'Unrestricted_Access, which allows you to violate the accessibility rules, but that's not portable. - Bob