From 8402581182139500211
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ccb40040597f37a7
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-03-08 21:26:46 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: brangdon@cix.co.uk (Dave Harris)
Newsgroups: comp.std.c++
Subject: Re: Extending enums (was Re: Forward declaration of enum)
Date: Sun, 9 Mar 2003 05:26:38 +0000 (UTC)
Lines: 45
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <memo.20030308151212.17663C@brangdon.madasafish.com>
References: <PNE21WKuwwiy-pn2-dMoOpvv8cPkQ@zamboni.stiscan.com>
X-Trace: mail2news.demon.co.uk 1047187599 5602 10.0.0.1 (9 Mar 2003 05:26:39 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sun, 9 Mar 2003 05:26:39 +0000 (UTC)
X-Received: from mulga.cs.mu.oz.au ([128.250.1.22])
	by news.demon.co.uk with esmtp (Exim 4.05)
	id 18rtKW-0001SD-00
	for mail2news@news.news.demon.net; Sun, 09 Mar 2003 05:26:37 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id QAA18413; Sun, 9 Mar 2003 16:26:32 +1100 (EST)
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Path: comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Delivered-To: std-c++@ncar.ucar.edu
X-Newsgroups: comp.std.c++
X-Reply-To: brangdon@cix.co.uk
X-Orig-NNTP-Posting-Host: pc1-clif1-6-cust113.nott.cable.ntl.com (80.4.200.113)
X-Orig-X-Trace: fu-berlin.de 1047136326 65979472 80.4.200.113 (16 [57443])
X-MailScanner: PASSED (v1.2.7 17224 h28FC7mZ027282 mailbox5.ucsd.edu)
X-Spam-Status: No, hits=-5.6 required=5.0
	tests=QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01
	version=2.41
Xref: archiver1.google.com comp.std.c++:18233

kgwzamboni-news@zambonistiscan.com () wrote (abridged):
> How about also making them more like real types.
> 
> enum Color( Red, Orange, Yellow );
> enum Fruit( Orange, Apple, Grapes );
> 
> Except when assigning them directly to ints, the compiler is capable
> of determining which Orange it is.

It is a bit dangerous to have names whose meaning depends on context. 


> For that case allow the cast like Color(Orange).

It's not really a cast; more of a name resolution. I think it is a shame 
enums do not have associated namespaces, so that we could write:

   enum Color { Red, Orange, Yellow };
   enum Fruit { Orange, Apple, Grapes };
   
   Colour c = Colour::Orange;

Currently the second line is ambiguous even if Orange is not used 
subsequently, and the Colour::Orange syntax is not permitted. As a 
workaround I usually put my own namespace, like:

   namespace Color { enum Type { Red, Orange, Yellow }; }
   namespace Fruit { enum Type { Orange, Apple, Grapes } };
   
   Colour::Type c = Colour::Orange;

which works, but it is clumsy (eg there is no good name for the thing I 
have called "Type").

  Dave Harris, Nottingham, UK | "Weave a circle round him thrice,
      brangdon@cix.co.uk      |   And close your eyes with holy dread,
                              |  For he on honey dew hath fed
 http://www.bhresearch.co.uk/ |   And drunk the milk of Paradise."

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



