Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!microsoft!jimad From: jimad@microsoft.UUCP (JAMES ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: const enums -- Lawyers opinions?? Keywords: const, enum Message-ID: <10215@microsoft.UUCP> Date: 10 Jan 90 17:36:40 GMT References: <963@rna.UUCP> <10197@microsoft.UUCP> <9925@ardent.UUCP> Reply-To: jimad@microsoft.UUCP (JAMES ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 24 >The question of what an enum type "really is", has bedeveled >the concept ever since it was introduced into C. Over the >years a lot has been said, but I believe a consensus finally >emerged and both ANSI C and the most recent C++ reference manual agree >that they are integral types. > >This means that its perfectly sensible to assign arbitrary integer >values to variables of enum type. > >Jerry Schwarz I would claim on the contrary that the decision by both ANSI-C and C++ to consider enums integral types is a pragmatic decision stating that strict type checking on enums is more of a pain than a help for programmers. I would claim that if one creates an enum for the days of the week and then store the integer 10000 in an instance of that enum, then you've made a programming mistake -- even if it is permissable according to the language definition. There are a lot of areas in C++ like that -- where the language for historical or pragmatic reasons allows programmers to do things that are generally very bad programming practice. I believe it is important that programs "scan" right to human readers -- if a variable claims to be of a certain enum, it should only hold legal values of that enum. To do otherwise is a bug. IMHO.