Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!rutgers!mcnc!ncsuvx!news From: dks@shumv1.uucp (D. K. Smith) Newsgroups: comp.lang.c Subject: Re: Enumerated types... what's the point? Message-ID: <1990Mar24.010203.26408@ncsuvx.ncsu.edu> Date: 24 Mar 90 01:02:03 GMT References: <8578@pt.cs.cmu.edu> <1990Mar23.234509.21638@aqdata.uucp> Sender: news@ncsuvx.ncsu.edu (USENET News System) Reply-To: dks@shumv1.ncsu.edu (D. K. Smith) Distribution: usa Organization: NCSU Computing Center Lines: 46 In article <1990Mar23.234509.21638@aqdata.uucp> sullivan@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@aqdata.uucp >San Dimas, CA +1 714 599 9992 dk smith