comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Problem with Enumaration and visibility
Date: Wed, 14 Nov 2001 15:28:28 GMT
Date: 2001-11-14T15:28:28+00:00	[thread overview]
Message-ID: <w4wI7.24376$xS6.38469@www.newsranger.com> (raw)
In-Reply-To: slrn9v4uqg.h34.randhol+abuse@kiuk0156.chembio.ntnu.no

In article <slrn9v4uqg.h34.randhol+abuse@kiuk0156.chembio.ntnu.no>, 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.



  parent reply	other threads:[~2001-11-14 15:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <slrn9v4uqg.h34.randhol+abuse@kiuk0156.chembio.ntnu.n o>
2001-11-14 13:03 ` Problem with Enumaration and visibility Preben Randhol
2001-11-14 13:48   ` Wilhelm Spickermann
2001-11-14 16:55     ` Preben Randhol
2001-11-14 15:28   ` Ted Dennison [this message]
2001-11-14 16:32   ` Jeffrey Carter
2001-11-14 17:25     ` Preben Randhol
2001-11-14 15:37 Hambut Frumblefoot
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox