Enumerated types... what's the point?
D. K. Smith
dks at shumv1.uucp
Sat Mar 24 11:02:03 AEST 1990
In article <1990Mar23.234509.21638 at aqdata.uucp> sullivan at aqdata.uucp (Michael T. Sullivan) writes:
>I missed the beginning of this discussion so forgive me if this has
>been gone over but has anybody mentioned the assignment of clashing
>enum variables? For instance:
>
THIS! is exactly the reason I posted the original article titled
"...what's the point", 'cuz I thought I was really getting some
mileage out of this *type*ing in the the language. I put this code to
my compiler (THINK C 3.02).... the results were expected. It took it
without a htich. I am new to C, however I still have an opinion. The
"typing" going on here is an illusion at best in my compiler. Did you
try this in your compiler? I do understand the positions of the C-gods
when decreeing the new standard to make as few apps break as possible.
But I still don't agree with it.
I think if this was implemented in the way that is intuitive to me it
would be a very powerful tool. Oh well...
>typedef enum { red, green, brown, yellow } colors;
>typedef enum { huey, dewey, louie } ducks;
>
>main()
>{
>colors a;
>ducks b;
>
> a = red;
> b = huey;
> a = 1
> a = b;
>}
>
>produces a compiler error at "a = 1" and "a = b". This makes sure people
>can't make an end run around the values a given variable should have,
>which they could easily do if #define's were used for the values.
Yeah right... I wish it was so in my compiler... :-)
>--
>Michael Sullivan uunet!jarthur!aqdata!sullivan
>aQdata, Inc. sullivan at aqdata.uucp
>San Dimas, CA +1 714 599 9992
dk smith
More information about the Comp.lang.c
mailing list