Thread View: net.lang.c
2 messages
2 total messages
Started by ed gokhman
Wed, 29 Oct 1986 21:30
what type is enum ?
Author: ed gokhman
Date: Wed, 29 Oct 1986 21:30
Date: Wed, 29 Oct 1986 21:30
3 lines
668 bytes
668 bytes
Is enumeration a fundamental or derived type considering that it always behaves as int according to X3JJ11 ? It seems to have problems being either one.
Re: what type is enum ?
Author: Henry Spencer
Date: Fri, 31 Oct 1986 22:59
Date: Fri, 31 Oct 1986 22:59
22 lines
1783 bytes
1783 bytes
> Is enumeration a fundamental or derived type considering
> that it always behaves as int according to X3JJ11 ?
> It seems to have problems being either one.
Neither. In X3J11speak, enum is not a distinct type at all. It's just a
way of giving names to a bunch of integer constants. Your compiler might
helpfully (?) provide warning messages unless you treat it strictly as a
distinct type, but that is not an X3J11 requirement.
It is agreed that this is not terribly satisfactory, but then enums never
were terribly satisfactory. The way existing compilers treat them is best
described as "confused". Thus X3J11 had to decide between trying to compose
a complete and consistent specification for their current behavior (probably
impossible), making them distinct types a la Pascal (which would break a lot
of existing C code), or simplifying them to named integer constants (less
than elegant, but the only practical approach). Actually, there was a fourth
choice: delete them from C altogether, leaving them as a non-standard
extension in some existing compilers. I gather there was long debate about
the matter (I'm not formally involved with X3J11, so I can't say for sure).
--
Henry Spencer @ U of Toronto Zoology
{allegra,ihnp4,decvax,pyramid}!utzoo!henry
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads