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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d121cc76e012fcca X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Library Level Question Date: 1999/02/15 Message-ID: #1/1 X-Deja-AN: 444645175 Sender: matt@mheaney.ni.net References: <36c853cb.0@news.pacifier.com> NNTP-Posting-Date: Mon, 15 Feb 1999 10:05:19 PDT Newsgroups: comp.lang.ada Date: 1999-02-15T00:00:00+00:00 List-Id: "Steve Doiel" writes: > What exactly is meant by Library Level I think of library level as the most outer scope of a system. Think of a real library. All the books in the library are at "library level." But if you open one of the books, and look at a diagram, then the diagram is _not_ at library level, because it's _inside_ the book. But the book itself is "inside" the library. All the things we think of as being inside the library are at library level (say, the things listed in the card catalog). In contrast, a diagram is "more nested," because it's inside the book, not inside the library (and the diagram would not be in the library's card catalog). > Section 13.10.2 of the LRM gives the following description: > > (22) > The accessibility level of all library units is called the library level; > a library-level declaration or entity is one whose accessibility level is > the library level. > > Does this mean unit specifications? Implementations? Either? > I'm obviously not a language lawyer, but am often able to figure things out > from the LRM. this has been an exception. This just means that when you have a package, not declared in anything else, as in package Book is ... end Book; that it is at library level. Just like our book. But if we have a package inside another, like this: package Book is package Diagram is ... end Diagram; ... end Book; then the inner package is _not_ at library level. The diagram is in the book, not the library. > My observation has been that when I try to take the address ('access) of a > function or procedure that is defined within my main procedure, I get a > message about the wrong library level. But if I take the address of a > function or procedure defined inside a package spec or body, the compiler is > happy. Because inside a procedure, you're not at library level, you're inside something. Stretching our analogy a bit, it's like trying to give a reference to a diagram, without having to also refer to the book, and that's illegal. You have a couple of choices: 1) Declare the subprogram you want to call via a pointer inside a package at library level: package Book is procedure Diagram; end; Now you can safely point to subprogram via a pointer. 2) If you're using GNAT, then you can go outside the Official Language by using 'Unrestricted_Access. You are then allowed to point to your local subprogram, without any complaints from the compiler. This "feature" of the language has been debated many times here on c.l.a. Go to DejaNews and search for "downward closures" to get more info.