const sucks
Walter Bright
newshound1 at digitalmars.com
Sat Oct 18 20:36:51 PDT 2008
Bill Baxter wrote:
> I think you mean "this option is being discussed *once again*". It
> was discussed quite a lot before the current invariant/const was
> implemented. The consensus was definitely that it was worth a shot.
> But it did not get a shot.
Yes, it was discussed a lot.
> I recall Walter's main argument against it was that local variable
> really shouldn't be const-by-default since you're usually creating
> them because you want to manipulate them. But then you end up with a
> system where local variable declarations and parameter declarations
> follow very different rules. "int[] foo" in one place means something
> different from "int[] foo" in the other place. I'm not convinced this
> would be that confusing, though. There could be other problems with
> const-by-default in parameters, but that one doesn't seem like such a
> big deal.
The problem is things like:
void foo(int[] a)
{
int[] b;
}
so a is const, and b is mutable? That's very confusing. It gives the
appearance of D having a lot of wacky and arbitrary semantic rules.
More information about the Digitalmars-d
mailing list