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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP, WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,83b83c553c3b79cf X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-14 07:28:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!nntp-relay.ihug.net!ihug.co.nz!out.nntp.be!propagator-SanJose!in.nntp.be!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: Subject: Re: Problem with Enumaration and visibility Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Wed, 14 Nov 2001 10:28:28 EST Organization: http://www.newsranger.com Date: Wed, 14 Nov 2001 15:28:28 GMT Xref: archiver1.google.com comp.lang.ada:16506 Date: 2001-11-14T15:28:28+00:00 List-Id: In article , Preben Randhol says... >I have defined a Enumarated type in a package called setup. I need to >use this in another package called Examine. If I do as below, I get this >error from GNAT: > > examine.adb:130:17: operator for type "Method_Enum_Type" defined at > setup.ads:64 is not directly visible > > examine.adb:130:17: use clause would make operation legal > examine.adb:130:47: "Spell" is not visible > examine.adb:130:47: non-visible declaration at setup.ads:64 .. >if I add "use Setup;" in the Start procedure it works. Why do I have >to do this? Is there a different way without using use. I'm just >asking to understand how this works with enumarated types. First off, this is a *really* basic issue, which would take a good deal of exposition to explain properly. I suggest you read an Ada book rather than have people here try to get into it. Chapter 2 of John English's book goes into this, if you don't have your own dead-tree book handy. See http://www.it.bton.ac.uk/staff/je/adacraft/ch02.htm . Go read that, then come back here. I'll wait... Now: Yes there is another way. Some (including myself) would argue that its is in fact the proper way to do it. What you do is prepend the package name in front of the name of every object in that package that you reference. For instance, in examine.adb, "Spell" would become "Setup.Spell". The second thing you will need to do is change that "use" clause to a "use type" clause for the type in question (Setup.Method_Enum_Type). That gives you direct visibility to built-in infix operators like "=". I highly suggest all newbies use this approach rather than just doing a "use" clause for the whole package, as it trains you to think about where you are getting things from. One you become proficient with Ada, you can decide for yourself if you need to continue working that way. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.