Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: Phil Bouchard Newsgroups: comp.std.c++ Subject: Re: New strongly type enum proposal featuring inherited enums Date: Wed, 24 Aug 2011 17:40:10 -0700 (PDT) Organization: albasani.net Lines: 37 Sender: std-cpp-request@vandevoorde.com Approved: stephen.clamage@oracle.com Message-ID: <4e55785a@news.x-privat.org> References: <4e49ea26$2@news.x-privat.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Trace: news.albasani.net qwonnWsASKlF6hdNDB9Eeb4Et/mxEg0vaASQJXq/1nOpQ8whf/bkLe5Xp6G4Vh9n5/mVnYr/eRwMBrReiWr5Bg== NNTP-Posting-Date: Thu, 25 Aug 2011 00:40:11 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="JDNSEgNhQgVYnYx2VkPwnBT55pPwtZzFAKwNDVlv5xLtW8ghC63/Zv5UMGQJ0bzW6mArSyAwCtA4irtdPV5c9FSufO70K7Odo3jSnBHAO85CUdg8bH7jpMK+fZxcUt8Y"; mail-complaints-to="abuse@albasani.net" X-Mailer: Perl5 Mail::Internet v2.05 X-Submission-Address: std-cpp-submit@vandevoorde.com Cancel-Lock: sha1:aTKjPXFMG76sS1rFVU+PgXgigLA= X-Original-Date: Wed, 24 Aug 2011 18:16:57 -0400 Xref: x330-a1.tempe.blueboxinc.net comp.std.c++:253 On 8/24/2011 5:06 PM, Seungbeom Kim wrote: > > It looks similar to a simple-declaration, but its syntax must be > something entirely different. You can neither put a semicolon at > the end of the list of the enumerators, nor use different types > for different enumerators. > I think this is a case where a syntax that is too similar but not the > same can be more confusing than a syntax that looks different enough. > We might face questions like '"int i1, i2;" is equivalent to "int i1; > int i2;" but why isn't it the case inside an enum?' > > Anyway, this is a matter of taste, after all. I think if inheritance is eventually supported then it would be very confusing having the ':' stand for both subtyping and inheritance. enum class WindowOptions : unsigned short { A, B, C }; enum class AdvancedWindowOptions : WindowOptions { D, E }; On the other hand if bitfields are supported as well, is the following what we want? enum class WindowOptions : unsigned short : 2 { A, B, C }; // ? enum class AdvancedWindowOptions : WindowOptions { D, E }; Here we have ':' with 3 different meanings. The following parses just like a real declaration: enum class WindowOptions { unsigned short A : 2, B : 2, C : 2 }; -Phil -- [ comp.std.c++ is moderated. To submit articles, try posting with your ] [ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]