comp.lang.ada
 help / color / mirror / Atom feed
From: blaak@infomatch.com (Ray Blaak)
Subject: Re: Enumeration literal visibility and use type
Date: 1998/05/26
Date: 1998-05-26T00:00:00+00:00	[thread overview]
Message-ID: <6kf612$iuj$1@berlin.infomatch.com> (raw)
In-Reply-To: 6kelnr$ief$1@polo.advicom.net


"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:
>John is correct.  The only way I've found to make the literals visible
>(without a context clause "use doodah;") is in the units requiring
>visibility is to declare:
>state_0 : constant doodah.state_value_type := doodah.state_0;
>Anyone have a better way?

I like doing:

  package doodah is
    package State is
      type Value is (state0, state1, ...);
    end State;
    ...
  end doodah;

  with doodah;
  procedure Main is
    use doodah.State;
    cool : doodah.State.Value := state0;
  begin
  end Main;

Another approach, especially when you only need the literals in a case
statement, is to do:

  package doodah is
    type state_value is (state0, ...);
    ...
  end doodah;

  with doodah;
  procedure Report_State(The_State : in doodah.state_value) is
    type states is new doodah.state_value; -- literals are now in scope
  begin
    case states(The_State) is
    when state0 => ...;
    when state1 => ...;
    ...
    end case;
  end Report_State;

Cheers,                                        The Rhythm is around me,
                                               The Rhythm has control.
Ray Blaak                                      The Rhythm is inside me,
blaak@infomatch.com                            The Rhythm has my soul.




  parent reply	other threads:[~1998-05-26  0:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-26  0:00 Enumeration literal visibility and use type William Bralick
1998-05-26  0:00 ` Matthew Heaney
1998-05-27  0:00   ` William Bralick
1998-05-27  0:00   ` Mats Weber
1998-05-27  0:00   ` John McCabe
1998-05-26  0:00 ` John McCabe
1998-05-26  0:00   ` David C. Hoos, Sr.
1998-05-26  0:00     ` Matthew Heaney
1998-05-27  0:00       ` John McCabe
1998-05-26  0:00     ` John English
1998-05-26  0:00     ` Ray Blaak [this message]
1998-05-27  0:00       ` John McCabe
1998-05-27  0:00         ` John McCabe
1998-05-27  0:00     ` Robert Dewar
1998-05-27  0:00       ` Matthew Heaney
1998-05-26  0:00 ` Roger Racine
     [not found] <6kej65$dnh$1@hermes.seas.smu.edu| <6kejt5$75u@gcsin3.geccs.gecm.com>
1998-05-26  0:00 ` William Bralick
1998-05-26  0:00   ` Fergus Henderson
1998-05-27  0:00     ` John McCabe
1998-05-27  0:00       ` Peter Amey
1998-05-27  0:00         ` John McCabe
1998-05-27  0:00       ` Robert Dewar
1998-05-28  0:00         ` John McCabe
1998-05-28  0:00           ` Robert Dewar
1998-05-29  0:00             ` John McCabe
1998-05-28  0:00           ` Thomas Hood
1998-05-28  0:00             ` Robert Dewar
1998-05-27  0:00     ` William Bralick
replies disabled

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