comp.lang.ada
 help / color / mirror / Atom feed
* "Use"ing Enumerated type values?
@ 1996-02-23  0:00 GAFFNEY.BRIAN
  1996-02-23  0:00 ` James A. Krzyzanowski
  1996-02-24  0:00 ` Robert A Duff
  0 siblings, 2 replies; 4+ messages in thread
From: GAFFNEY.BRIAN @ 1996-02-23  0:00 UTC (permalink / raw)


I'm trying to write a program utilizing the ANSI screen package posted by Ray
Toal.  What I'd like to do for clarity is something like this:
--
with Text_IO;
with Ansi_Terminal;
procedure Test_Ansi is
  package Ansi renames Ansi_Terminal;
  ForeGrd, BackGrd : Ansi.Color;   -- type Color is (Black,..., White);
begin
  Ansi.Erase_Display;
  BackGrd := White;			--Error, White not visible
  ForeGrd := Black;  			--Error, Black not visible
  Ansi.Set_Character_Colors (BackGrd, ForeGrd);
  Text_IO.Put("This should be home.");
end Ansi_Test;
--
However, to use the values for Ansi.Color, I need to specify "Ansi.White" and
"Ansi.Black".  I'd like to use the values of Color without the "Ansi."
everytime.  Since I don't want to "use" Ansi_Terminal, I thought "use type
Ansi.Color" would work but I still can't use the values directly.  If I define 
my own Color as a subtype of Ansi.Color, I can define my variables as Colors, 
and refer to the values of Color, but I can't use these variables as parameters
to routines in Ansi (they expect type Ansi.Color).

Is there any way to refer directly to the values of a type without "use"ing the
entire package?

BTW I'm "use"ing GNAT 3.01 on DOS(DJGPP).

-- LONG pause while I check the RM --

The RM seems to indicate that "use type" is intended for using operations of
the type, so I guess it doesn't work with values... (?)

					--Bg 




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Use"ing Enumerated type values?
  1996-02-23  0:00 "Use"ing Enumerated type values? GAFFNEY.BRIAN
@ 1996-02-23  0:00 ` James A. Krzyzanowski
  1996-02-24  0:00   ` Robert Dewar
  1996-02-24  0:00 ` Robert A Duff
  1 sibling, 1 reply; 4+ messages in thread
From: James A. Krzyzanowski @ 1996-02-23  0:00 UTC (permalink / raw)


GAFFNEY.BRIAN (gaffney@ewir-wr) wrote:
: I'm trying to write a program utilizing the ANSI screen package posted by
: Ray Toal.  What I'd like to do for clarity is something like this:
: --
: with Text_IO;
: with Ansi_Terminal;
: procedure Test_Ansi is
:   package Ansi renames Ansi_Terminal;
:   ForeGrd, BackGrd : Ansi.Color;   -- type Color is (Black,..., White);
: begin
:   Ansi.Erase_Display;
:   BackGrd := White;			--Error, White not visible
:   ForeGrd := Black;  			--Error, Black not visible
:   Ansi.Set_Character_Colors (BackGrd, ForeGrd);
:   Text_IO.Put("This should be home.");
: end Ansi_Test;
: --
: However, to use the values for Ansi.Color, I need to specify "Ansi.White" and
: "Ansi.Black".  I'd like to use the values of Color without the "Ansi."
: everytime.  Since I don't want to "use" Ansi_Terminal, I thought "use type
: Ansi.Color" would work but I still can't use the values directly.  If I define 
: my own Color as a subtype of Ansi.Color, I can define my variables as Colors, 
: and refer to the values of Color, but I can't use these variables as parameters
: to routines in Ansi (they expect type Ansi.Color).

: Is there any way to refer directly to the values of a type without "use"ing the
: entire package?

In Ada83, you can do the following; although it is NOT recommended (I
would recommend that you just use the "package"."value")...

  function Black return Ansi.Color renames Ansi.Black;
  function White return Ansi.Color renames Ansi.White;
  ...

--
Not necessarily the opinion of the company...
--
---------------------------------------------------------------------------
         James A. Krzyzanowski - Senior Software Engineer - AFATDS
Magnavox Electronic Systems Company * Fort Wayne, IN 46808 * (219) 429-6446
Internet: jakrzy@most.fw.hac.com * AOL: JimShiz@AOL.com * MOST: jakrzy@most
            "I'd rather be right than politically correct !!!"
---------------------------------------------------------------------------




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Use"ing Enumerated type values?
  1996-02-23  0:00 "Use"ing Enumerated type values? GAFFNEY.BRIAN
  1996-02-23  0:00 ` James A. Krzyzanowski
@ 1996-02-24  0:00 ` Robert A Duff
  1 sibling, 0 replies; 4+ messages in thread
From: Robert A Duff @ 1996-02-24  0:00 UTC (permalink / raw)


In article <23FEB199614115172@ewir-wr>, GAFFNEY.BRIAN <gaffney@ewir-wr> wrote:
>Is there any way to refer directly to the values of a type without "use"ing the
>entire package?

No.

>The RM seems to indicate that "use type" is intended for using operations of
>the type, so I guess it doesn't work with values... (?)

Operators.  Not operations.  That is, "use type" makes "+", "=", "and",
"xor", etc., visible (assuming whatever type it is has those operators).
And it's only the *primitive* operators -- the predefined ones, plus any
user-defined ones that are declared in the same package.

- Bob




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: "Use"ing Enumerated type values?
  1996-02-23  0:00 ` James A. Krzyzanowski
@ 1996-02-24  0:00   ` Robert Dewar
  0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1996-02-24  0:00 UTC (permalink / raw)


": Is there any way to refer directly to the values of a type without "use"ing th
e
: entire package?"

This always strikes me as odd. It is like saying "Is there a way of flying
to England without going in a plane."

Either you think things should be qualified or you don't. If you are happy\
to use functions (enumeration literals) from the package without
qualification then USE is there in the language for this purpose!





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1996-02-24  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-02-23  0:00 "Use"ing Enumerated type values? GAFFNEY.BRIAN
1996-02-23  0:00 ` James A. Krzyzanowski
1996-02-24  0:00   ` Robert Dewar
1996-02-24  0:00 ` Robert A Duff

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