Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: C++ features for C Date: Sat, 12 May 2018 12:17:30 -0700 Organization: None to speak of Lines: 44 Message-ID: References: <11edbfd7-461d-4579-8ac7-a9e84a6b7630@googlegroups.com> <7b110d3e-ddb5-42a0-af99-aa5b0cb30832@googlegroups.com> <13efc313-d10c-4357-9aa7-6fa55b09d948@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="b241fefa6b912bdefe83ae72b0e16b14"; logging-data="29046"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yxtCzTUrVOWsuh3D7PBah" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:MLansUX0cu7y4rSu3j658HasbEg= sha1:uXEFJYyP0jMHuLtlBi+EY6oM+t0= Xref: csiph.com comp.lang.c:130461 bartc writes: [...] > As for the issues with 'register const': > > * IME named constants are typically defined outside of functions, > but using 'register const' there seems problematical with some > compilers It's not just "problematical with some compilers". Using "register" on the definition of an object outside a function definition is a constraint violation. > * I had problems using a register const name as a case label. (I can't > test for array bounds as C99 compilers will silently create a VLA.) A case label must be a constant expression. The name of a const-qualified object (register or not) is not a constant expression. > * Register consts inside functions can be assigned non-compile-time > expressions Certainly. "const" means read-only. It never makes something a constant expression. And to preempt what you're probably about to say, I am describing the language, not defending it. > Maybe some people can't see the problems here, for example you can just > use enums for case labels or array bounds. But it still seems that an > all-on-one solution to the very simple requirement of scoped, named > literals is elusive. Some people can't see the problems, which is why nobody is proposing better ways to define named compile-time constants. Oh, wait, that's what we're doing in this thread. And most of us realize that it's important to understand the existing language rules before proposing new features. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"