Re: Enumeration data type

"Mike Dimmick" <mike@dimmick.demon.co.uk>
19 Jan 2001 23:23:22 -0500

          From comp.compilers

Related articles
Enumeration data type irobot@swbell.net (Brian Webb) (2001-01-18)
Re: Enumeration data type iRobot@swbell.net (Brian Webb) (2001-01-19)
Re: Enumeration data type tim.vanholder@falconsoft.be (Tim Van Holder) (2001-01-19)
Re: Enumeration data type kszabo@nortelnetworks.com (Kevin Szabo) (2001-01-19)
Re: Enumeration data type mike@dimmick.demon.co.uk (Mike Dimmick) (2001-01-19)
| List of all articles for this month |

From: "Mike Dimmick" <mike@dimmick.demon.co.uk>
Newsgroups: comp.compilers
Date: 19 Jan 2001 23:23:22 -0500
Organization: Compilers Central
References: 01-01-081
Keywords: types, Ada
Posted-Date: 19 Jan 2001 23:23:22 EST

"Brian Webb" <irobot@swbell.net> wrote in message
> I'm planning on adding the ability to create "sets of typed constants"
> to a language that I'm designing, but feel that using the term
> "enumeration" may be confusing. What's a good name to use for the
> following constructs.
>
> They're like enumerations, except that values may be assigned and data
> types other than integer can be used.
>
> enumeration Color_Code is integer
> Black = 0
> Red = 1


> enumeration Probability is real
> None = 0.0
> Low = 0.1


> enumeration Elements is Element
> Hydrogen = (Element) ("H", 1, 1.0079)
> Deuterium = (Element) ("H", 1, 2.0000)


> constant set of Elements Inert is (Helium, Neon)
>
> Any thoughts on a good terminology for these items. Don't read
> anything into the sample data, it's purely made up.


Ada divides the concepts into two; you can specify an enumeration:


TYPE Color_Code IS (Black, Red, Green, Blue, White);


then specify which values you want used for the members of the enumeration:


FOR Color_Code USE (
        Black => 0,
        Red => 1,
        Green => 2,
        Blue => 8,
        White => 16
);


I don't know if this helps you at all. There's an online reference
manual (I think it can be found somewhere on www.adapower.com); the
relevant sections are 3.5.1 (Enumeration Types) and 13.4 (Enumeration
Representation Clauses).


HTH,
--
Mike Dimmick


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.