Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!sunic!tut!tukki!sakkinen From: sakkinen@tukki.jyu.fi (Markku Sakkinen) Newsgroups: comp.lang.c++ Subject: Re: enums Keywords: enum subrange array index Message-ID: <2705@tukki.jyu.fi> Date: 15 Jan 90 13:46:13 GMT References: <963@rna.UUCP> <10197@microsoft.UUCP> <9925@ardent.UUCP> <10215@microsoft.UUCP> <2205@plx.UUCP> Reply-To: sakkinen@jytko.jyu.fi (Markku Sakkinen) SAKKINEN@FINJYU.bitnet (alternative) Organization: University of Jyvaskyla, Finland Lines: 40 In article <2205@plx.UUCP> johnc@plx.UUCP (John Ciccarelli) writes: >Having used full-featured enums (and subranges -- *sigh* ) >in other languages, this debate about "should you be prevented from >assigning an int to an enum without a cast" seems like needless >hand-wringing. IMHO, *of course* you shouldn't be allowed to do this >without a cast (this is to offend some diehard original-C types I know). Seconded. In his "The C Book : Featuring the draft ANSI C Standard" (Addison-Wesley 1988), Mike Banahan introduces ANSI enum types approximately: "These belong to the category of half-baked." At the end of the section, I think he asks any reader who invents a good application for this kind of enumerations to inform him too. (The book is recommended especially to people who like the wry British kind of humour.) > [...] > >By 'full-featured' enums, I meant (for one thing) the ability >(in other languages) to declare an array with an 'enum' subscript: > > int fruitPrice[ Fruit ]; > >This is so simple but so powerful. In the "C++ Primer" I didn't >see a way to do this, probably because it presupposes arrays with >non-zero base subscripts, which I'm pretty sure C++ also lacks. >Both features are conceptually simple but greatly improve readability >and robustness. Ditto subrange types. Perhaps you should look around for other OO languages than C++ ... Readability and robustness aren't important goals in the C world. By the way, Niklaus Wirth himself has eradicated enumerations, subranges, and several other things from his newest language Oberon, the successor of Pascal and Modula-2, which is mildly object-oriented. I think he has overdone it. Markku Sakkinen Department of Computer Science University of Jyvaskyla (a's with umlauts) Seminaarinkatu 15 SF-40100 Jyvaskyla (umlauts again) Finland