From: Jeffrey Carter <jeffrey.carter@boeing.com>
Subject: Re: Problem with Enumaration and visibility
Date: Wed, 14 Nov 2001 16:32:58 GMT
Date: 2001-11-14T16:32:58+00:00 [thread overview]
Message-ID: <3BF29CBA.46D5F9B2@boeing.com> (raw)
In-Reply-To: slrn9v4uqg.h34.randhol+abuse@kiuk0156.chembio.ntnu.no
Preben Randhol wrote:
>
> package Setup is
> -- ...
>
> type Method_Enum_Type is (Spell, MChoice);
>
> procedure Get_Method return Method_Enum_Type;
> -- ...
> end Setup;
>
> with Setup;
>
> package body Examine is
>
> -- ...
>
> procedure Start is
> Method : Setup.Method_Enum_Type := Setup.Get_Method;
> begin
> if Method = Setup.Method_Enum_Type'(Spell) then
> Examine.Spelling.Start;
> end if;
> end Start;
This has nothing specifically to do with enumeration types. Anything
declared in a package specification is not directly visible outside the
package.
In the fragment of Setup shown, you declare a type, 2 enumeration
literals (which are actually functions), a function (I presume, though
you call it a procedure). The type declaration implicitly declares a
number of operations, including "=", "/=", "<", ">", and so on. None of
these things are directly visible outside the package without a use
clause.
In Examine, you reference the type (Method_Enum_Type), an operation
("="), and an enumeration literal (Spell). Without a use clause, none of
these are directly visible; they must all be prefixed with "Setup.". You
did this for the type, but not for the operation or literal.
You have a number of choices:
1. Prefix everything:
if Setup."=" (Method, Setup.Spell) then
2. Add "use Setup;". This eliminates the need to prefix anything.
3. Add "use type Setup.Method_Enum_Type;". This eliminates the need to
prefix "=", but you will still need to prefix Spell.
4. Rename the operations of interest:
function "=" (Left, Right : Setup.Method_Enum_Type) return Boolean
renames Setup."=";
function Spell return Setup.Method_Enum_Type renames Setup.Spell;
if Method = Spell then
5. Some combination of the above.
This situation arises for anything declared in one package but
referenced elsewhere.
--
Jeffrey Carter
next prev parent reply other threads:[~2001-11-14 16:32 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
2001-11-14 16:32 ` Jeffrey Carter [this message]
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