On 12.12.2010 1:20, Simen kjaeraas wrote:
Jonathan M Davis <jmdavisp...@gmx.com> wrote:
It has definitely been suggested before that const should be the
default, and
some people would love that, but there's no way that it's going to
happen in D2,
and much as I like const, I think that it would be a huge mistake to
do it in
any version of D and likely any version of any C-based language. It's
too big of
a break with other versions of D and other C-based languages.
I'm torn about the issue. I see reasons to have const by default (or even
immutable), but having it as the 'real' default would as you say, turn
away too many programmers.
Hence, I suggest that modules may be marked default-const:
const module foo;
int n; // const int
mutable int m; // int
This could also be extended to cover pure:
pure const module foo;
Is this a good idea? No idea.
I think you could still get something very related by
const {
// entire module here
}
That of course, doesn't affect locals.
--
Dmitry Olshansky