From -7911035634525957247
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,ccb40040597f37a7
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2003-03-10 06:32:57 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!kibo.news.demon.net!mutlu.news.demon.net!demon!mail2news.demon.co.uk!devnull
From: dsp@bdal.de (Daniel Spangenberg)
Newsgroups: comp.std.c++
Subject: Re: Extending enums (was Re: Forward declaration of enum)
Date: Mon, 10 Mar 2003 14:32:52 +0000 (UTC)
Lines: 47
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <3E6C739E.9850D2A5@bdal.de>
References: <PNE21WKuwwiy-pn2-dMoOpvv8cPkQ@zamboni.stiscan.com> <memo.20030308151212.17663C@brangdon.madasafish.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: mail2news.demon.co.uk 1047306772 19975 10.0.0.1 (10 Mar 2003 14:32:52 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Mon, 10 Mar 2003 14:32:52 +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 18sOKf-0005C1-00
	for mail2news@news.news.demon.net; Mon, 10 Mar 2003 14:32:51 +0000
X-Received: from localhost (localhost [[UNIX: localhost]]) by mulga.cs.mu.OZ.AU
	id BAA09485; Tue, 11 Mar 2003 01:32:20 +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-Accept-Language: de
X-Newsgroups: comp.std.c++
X-Spam-Status: No, hits=-5.0 required=5.0
	tests=QUOTED_EMAIL_TEXT,REFERENCES,SPAM_PHRASE_00_01,
	      USER_AGENT_MOZILLA_XM,X_ACCEPT_LANG
	version=2.41
Xref: archiver1.google.com comp.std.c++:18244

Dave Harris schrieb:

> 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").
>

For the same reason, I nearly always encapsulate enumeration definitions into
classes,
like

struct Color { enum Type { Red, Orange, Yellow }; };

because I like the stronger enforcement of the complete name resolution of
class namespaces.

Why do you think, that Color::Type" is not a convenient identifier? Actually
I use the same
identifier and I think it is both short and self-explaining.

Greetings from Bremen/Germany

Daniel Spangenberg


---
[ 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                       ]



