Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: my solution for Pascal strings Date: Sat, 28 Mar 2015 20:04:41 -0700 Organization: None to speak of Lines: 50 Message-ID: <87y4mgld12.fsf@kst-u.example.com> References: <52a5b8b7-8c35-4a96-a438-bf173a427e95@googlegroups.com> <20141223141323.231@kylheku.com> <1wnmw.309290$td6.28533@fx30.am4> <3db88ab4-eecb-468d-8cb1-c659bbac140d@googlegroups.com> <87fv8qmev6.fsf@kst-u.example.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="c77ff4d35e33d1c939d3461ebde8dd0d"; logging-data="24205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/zm2qoPtCP14dbBBV0Y4cs" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:FVj3ZDZyO5NBnVVff2xPQjLJRAU= sha1:FdL7DE0iCppwcE/sqsLiqqlkAoU= Xref: csiph.com comp.lang.c:59187 Ian Collins writes: > Tim Rentsch wrote: >> Ian Collins writes: >>> Keith Thompson wrote: >>>> Bartc writes: >>>>> Etc. But in one or two megathreads in the past, people here >>>>> have expressed no desire to have such a simple and obvious >>>>> feature in the language, preferring the /possible/ adoption of >>>>> the 'constexpr' feature from C++, perhaps sometime later this >>>>> century. 'constexpr' is an version of C's 'const' which has >>>>> even more issues than const. >>>> >>>> I'm not familiar with constexpr. Perhaps I'll look into it. >>> >>> You should. Amongst other goodies it avoids that largely >>> pointless impediment to the evolution of C "breaking existing >>> code". >> >> Can you elaborate on that last statement? I'm familiar with >> constexpr, but I don't see what you're getting at with either >> part of the last sentence. > > Too many useful additions to C are rejected because they might break > fragile legacy code. C++ has evolved more rapidly than C in part > because the committee recognises that there is a cost/benefit tradeoff > to be made with new features. Making string literal const and cost > really cost were early examples of this. I presume you mean "const really const". But as I understand it C++ didn't do that. "const" still means read-only. C++ just added a special case whereby the name of a const-qualified object is treated as a constant expression if its initializer is a constant expression (something I'd like to see in C). So this: const int this_is_a_constant = 42; switch (expr) { case this_is_a_constant: // ... } is valid in C++ but not in C, but this: const int this_is_not_a_constant = rand(); is still valid in both C and C++. -- 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"