const debacle
Bill Baxter
dnewsgroup at billbaxter.com
Mon Mar 24 08:42:17 PDT 2008
Janice Caron wrote:
> On 24/03/2008, Bill Baxter <dnewsgroup at billbaxter.com> wrote:
>> As time wears on I find myself not becoming any more enthusiastic about
>> const in D...
>> All I wanted was a simple way to avoid simple mistakes in my code. Not
>> a complicated way to avoid complicated mistakes. And certainly not a
>> complicated way to avoid simple mistakes.
>
> The feature which is being requested, and rejected, is *not available
> in C, or C++, or any other language of which I am aware*.
>
> Therefore, the fact that it's also not available in D is hardly a criticism!
I was hoping for something simpler and less redundant than C++'s const.
Doesn't seem like it's going to be the case. The more I think I about
it the more I think I don't really care about transitivity and rock
solid assurances. I just want a simple way to prevent shooting myself
in the foot in really dumb obvious ways.
...And this:
#include <stdio.h>
char* substring(int begin, const char* string)
{
//string[0] = 'b';
return string+begin;
}
int main(int argc, char* argv[])
{
char * foo = "hi there\n";
char * bar = substring(3, foo);
printf(bar);
}
compiles in C with the line commented; doesn't compile if you uncomment
it. (Though gcc does give a warning in the former case.)
--bb
More information about the Digitalmars-d
mailing list