comp.lang.ada
 help / color / mirror / Atom feed
From: "Marc A. Criley" <mcqada@earthlink.net>
Subject: Re: Question about enumeration types
Date: Tue, 24 Jul 2001 12:31:03 GMT
Date: 2001-07-24T12:31:03+00:00	[thread overview]
Message-ID: <3B5D5E18.CA8BE58C@earthlink.net> (raw)
In-Reply-To: 3B5D5EA5.F20EC9D7@ffi.no

Reinert Korsnes wrote:
> 
> Hi,
> 
> (sorry for somehow repeating a question)
> 
> Given the program as below.  Here I did put "E : E1" inside
> a record since "E" is also a possible value for the enumeration type E1.
> 
> This is somehow verbose.  Is it a more elegant way ?
> 
> I find it boring that extending the range of possible values of
> an enumeration type may easily cause conflicts with variable names,
> and new variable names may cause conflicts values for enumeration
> types.  I sometimes would like to have the reserved word "Exit"
> as a possible value of an enumeration type....  Am I thinking
> somewhat wrong ?

Well, if you add a variable name, a type name, a procedure name, etc.,
you also have to worry about about causing conflicts with existing
variable, type, procedure, etc., names that have the same visibility, so
there's nothing particularly different about adding enumeration
literals.

One technique I've seen used is to prefix each enumeration literal with
its type name or some other convention.  For your example:

   type E1 is (E1_A, E1_B, E1_C, E1_D, E1_E);

Now you can add E1_Exit with no problem.

Marc A. Criley
Senior Staff Engineer
Quadrus Corporation
www.quadruscorp.com



  parent reply	other threads:[~2001-07-24 12:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-24 11:40 Question about enumeration types Reinert Korsnes
2001-07-24 12:23 ` Larry Hazel
2001-07-24 12:31 ` Marc A. Criley [this message]
2001-07-26 16:52 ` Robert Dewar
2001-07-27 13:04   ` Ken Garlington
2001-07-31  9:59   ` Peter Hermann
replies disabled

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