Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #8096

Re: enum escaping keywords

From Victor Bazarov <v.bazarov@comcast.invalid>
Newsgroups comp.lang.c++
Subject Re: enum escaping keywords
Date 2011-07-22 13:52 -0400
Organization A noiseless patient Spider
Message-ID <j0cdd5$t77$1@dont-email.me> (permalink)
References <j0c9t4$e8p$1@online.de> <j0cbg0$2519$1@news.ett.com.ua> <j0ccd8$gdh$1@online.de>

Show all headers | View raw


On 7/22/2011 1:35 PM, Philipp Kraus wrote:
> On 2011-07-22 19:19:31 +0200, Balog Pal said:
>
>> "Philipp Kraus" <philipp.kraus@flashpixx.de>
>>> I create a enum type with language codes like:
>>> enum lang {
>>> en,
>>> it,
>>> de,
>>> asm,
>>> or
>>> }
>>>
>>> but some codes are keywords (asm, or). How can I escape them, so that
>>> I can use them like
>>> lang::or or lang::asm ?
>>
>> Those are reserved words. You can not use them as identifiers. chose a
>> different form like Asm, asm_, l_asm, ...
>
> Is there no other solution !?

<shrug>  There probably is.  Instead of introducing an identifier that 
is illegal because it's a keyword, you could introduce a string literal...

 > Because the language codes are defined in
> the ISO 639, so I would like to use the defined
> codes as a enum value. I wouldn't create a own value

<shrug again>  I would like my variables to be named 'new', 'delete', 
and 'for'.  I can't, however.  So?

V
-- 
I do not respond to top-posted replies, please don't ask

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

enum escaping keywords Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-07-22 18:52 +0200
  Re: enum escaping keywords "Balog Pal" <pasa@lib.hu> - 2011-07-22 19:19 +0200
    Re: enum escaping keywords Philipp Kraus <philipp.kraus@flashpixx.de> - 2011-07-22 19:35 +0200
      Re: enum escaping keywords Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-22 13:52 -0400
  Re: enum escaping keywords James Kanze <james.kanze@gmail.com> - 2011-07-22 13:02 -0700
  Re: enum escaping keywords "James" <no@spam.invalid> - 2011-07-22 16:37 -0700

csiph-web