ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/04/17/10:07:23

From: j DOT aldrich6 AT genie DOT com
Message-Id: <199604171347.AA035968842@relay1.geis.com>
Date: Wed, 17 Apr 96 13:28:00 UTC 0000
To: djgpp AT delorie DOT com
Mime-Version: 1.0
Subject: Re: Enum Definitions

Reply to message 4728013    from KUKU AT GILBERTO on 04/17/96  3:37AM


>I didn't want to suggest sincerely using farse,tlue as variables
>in the program (that's why I used a smiley).

Oh, I know.  It gave me a good laugh, too.  :)  But I still wanted to make
my point.

>When we are at judging
>about style I would state that defining a pair of boolean variables
>as an enum is bad style anyway since I'm not sure where is guaranteed
>that the compiler always chooses the value 0 for the first
>entry in the enum list - maybe it's defined in ANSI somewhere.
>At least I would consider it dangerous.

I think ANSI does specify that the first enumerated value is automatically
zero.  But you are right in thinking that using enums can mask the actual
significance of the values.  I can imagine some novice who depends too
much on enums doing something like "if ( (exp) == true )" and getting
creamed.  :)  In fact, the only real reason for using enums at all is for
preventing coding errors. A series of #defined constants usually works
just as well unless you are really concerned about debugging.

John

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019