Hello hasen,

I haven't been following D for over a year .. now I notice there's a
const!!

[...]

This is annoying because now const propagates like a virus!

Yes const is viral (that can't be avoided)

This whole stupid process wouldn't even be needed in the first place
if C++ had a garbage collector, because then I would always "new" them
(as per Java, C#, and D)

SomeType *obj = new SomeType();

but because there's no garbage collector, I have to create the object
not as a reference.

SomeType obj();

Again, this is all stupid C++ stuff that shouldn't even be needed in
the first place.


IIRC const has exactly zero to do with new/reference/value stuff. It is totaly about knowing if somthing will get changed out from under you. This is needed to make unsable large scale libraries. And has a HUGE impact on parallel code.

However, with all that being said, that's just my opinion, maybe over
the time some people found some actually useful uses for const, great,
so they can use it if they want.

[...]

char[] p = "world"; // error, cannot implicitly convert invariant
// to mutable
and all I can think of is: WHAT - THE - HELL??!!!!!!

That's totally correct. On linux under D1.0 (that would work BTW) if you then try to alter p you get an access violation. String literals can't be modified and that what const/invariant says.


Reply via email to