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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,668255690a14abb2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-20 14:37:58 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!news.mathworks.com!uunet!ash.uu.net!world!bobduff From: Robert A Duff Subject: Re: Compiler complaint legal? Sender: bobduff@world.std.com (Robert A Duff) Message-ID: Date: Wed, 20 Jun 2001 21:33:00 GMT References: Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.3/Emacs 19.34 Xref: archiver1.google.com comp.lang.ada:8943 Date: 2001-06-20T21:33:00+00:00 List-Id: "M. A. Alves" writes: > Package O defines type O. GNAT does not recognize the type here: > > with O; use O; > procedure O_Test is > Object: O; -- HERE > Academic question: is this a legal complaint from a (aledgedly) validated > compiler? Yes. Package O hides type O. > (GNAT says "subtype mark required in this context" which I find confusing > because one does not immediately realise that what he is missing is a > "subtype indication" but this is another story I think.) The compiler first looks for all the O's that are direcly visible. There's only one -- the package (the type is hidden). Then it considers whether this thing is legal in this context -- it isn't, because the thing after the colon should be the name of a subtype, not the name of a package. That's why you get the "confusing" error message. The visibility rules are spelled out in excruciating detail in chapter 8 of the RM. The particular case here is: use_clauses are considered last. If there's an O visible in some outer scope, it will hide any O in a 'use'd package (assuming they're not overloadable, as is the case here). When you say "with O;" that makes it visible in an outer scope (namely, the scope of Standard). If you choose to give your packages and types the same name (which I don't think is a very good idea), then you will not be able to refer to the type by its simple name -- you'll have to say O.O. My style (when I'm using use clauses) is to call the package by the plural of the type name: package Lists contains type List, or package Symbol_Tables contains type Symbol_Table. Another style I've seen is to *always* call the type by a particular name, (say, T) and always use dot-notation to refer to it: Lists.T, Symbol_Tables.T. Here, the name T doesn't give any useful information, other than the fact that it's a type (or it's the "main" type exported by that package). The useful information is embodied in the package name. I've also seen "Object" used in place of "T". I don't really like that style... - Bob