Schol-R-LEA wrote:
the enum keyword was a relatively late addition, being introduced in the ANSI standard in 1989. It was something of an afterthought, meant to appease the Ada and Pascal fans who were being force to use C as it became an all-consuming juggernaut, but the intention was thought to be clear from the name. Apparently not.[/i]
I can't speak for ADA but in Pascal the idea was far more concerned with the internal semantics of the programme being visible in the code. Thus, you would have types such as:
Suit=(Clubs, Diamonds, Hearts, Spades)
Season=(Spring, Summer, Autumn, Winter)
House=(Coopers, Maples, Mellers, Whites)
FileSystem=(EXT2, EXT3, EXT4, FAT12, FAT16, FAT32, NTFS)
The first two do have some sort of ordering idea, but the last two don't apart from being in a conventional alphabetic order
The motivation, however, is
(a) to make the code reflect what is being done (the ultimate ideal would be for the code to be self-documenting):
if (DriveFileSystem==FAT12) {
print("Time to upgrade your system, mate")
}
(b) to make it difficult to assign values that are meaningless to the program:
DriveFileSystem=5
Error: Cannot assign integer to variable of type 'FileSystem'
or
DriveFileSystem=Hearts
Error: Hearts is not a FileSystem.
That's not to say that the ordering was not both used and useful, but I think it is wrong to regard it as a prime reason for the construct.