Re: Enumeration data type

"Kevin Szabo" <kszabo@nortelnetworks.com>
19 Jan 2001 23:21:57 -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: "Kevin Szabo" <kszabo@nortelnetworks.com>
Newsgroups: comp.compilers
Date: 19 Jan 2001 23:21:57 -0500
Organization: Nortel Networks (Ottawa, Ontario, Canada)
References: 01-01-081
Keywords: types
Posted-Date: 19 Jan 2001 23:21:57 EST
Originator: kszabo@nortel.ca (Kevin Szabo)
X-Orig: <kszabo@americasm01.nt.com>

Brian Webb <irobot@swbell.net> wrote:
>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.


Finding a good name is imperative, since I find that naming is (for
me) the essence of a good design. If I can't name it, then the
concept/role is muddled.


So, for your example you called it a set of typed constants, but I
think that was not completely correct. I think you meant 'sets of
named constants'. Things to think about is how these are used, for
example are they included (and searched) like a namespace when you are
trying to resolve symbols in your language. Is the order preserved?
Can you interate over them (successor, predecessor operations?)


The smalltalk language contains something like what I think you want.
It is called a 'Pool' or 'PoolDictionary'. Essentially they are a
dictionary (aka MAP in C++ STL) of name-value pairs (Associations)
where the value is assumed to be constant. When you define a class in
the Smalltalk language you include a list of 'pools' that are searched
when symbols are resolved, thus providing a bucket of constants that
are not in the global scope.


I personally didn't care much for pool variables; I prefered creating
a class that provided a method (function) that would return the
constant. Provided all the utility of pools without adding another
(low value) concept to the language.


Cheers,
Kevin


Post a followup to this message

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