Do we really need const?
Lionello Lunesu
lio at lunesu.remove.com
Mon Sep 17 04:29:42 PDT 2007
Just a quick note to say that I also have never missed "const" in D and
am reluctant to start with D 2.0 because of the added complexity. Walter
has said himself that while porting Phobos to 2.0, he has not
encountered, let alone fixed, a single bug. For me,
const/final/invariant is just not worth it.
I like const conceptually, but then there are many similar concepts that
are nice and const is just one of them.
D should opt for a more general red code / green code mechanism, as
explained by Scott Meyers in the next video:
http://video.google.com/videoplay?docid=-4728145737208991310
Pure/not-pure, throw/no-throw, const/not-const,
threadsafe/not-threadsafe etc. are all similar and I would love to see
one solution for all these red/green restrictions.
L.
PS. I'm playing around with the idea to add keywords after a function
declaration to add labels to the function. The compiler should then only
accept calls to functions with at least the labels of the caller:
void bar() throw;
void foo() { bar(); }//ERROR, bar can throw
void foo2() throw { bar(); } //OK
void foo3() throw { bar() throw; } //OK ("cast")
Or something to that effect. Possible using "!" to negate (!throw). I
have not thought this through more than what's written here and have no
idea what it would imply for the grammar.
More information about the Digitalmars-d
mailing list