Extended Type Design.

Dan murpsoft at hotmail.com
Fri Mar 16 12:18:48 PDT 2007


Wow...

I've never put this much thought into const/final stuff.  Ultimately, the program *cannot* prevent data in memory from being changed.  It can at best prevent you from accidentally changing it; hence final and const declarations mean "I don't want anyone to change these, can you raise an error if someone tries to within D?"

Also, the problem breaks down to 'what am I declaring const?'.  If I declare:

const int* x; // is it the pointer, or the int?

This doesn't seem important until you get to:

const int[int**][]* x; // now what is it?

Ultimately, you have this problem going through each and every pointer, array and value.  You could theoretically write this:

const int[int**][]*[char[]][3][17][3,17]* x;  and now what are you going to do?  declare it:

final const final final const const final final final final final const?
Even final const! super const! final! const! doesn't work, in fact I agree it makes it worse.

Good luck getting readability with that.

Ultimately, something else needs to be developed.

Perhaps a character we can use in alongside each item on the type declaration, or we need to be able to hit the whole line in one blow.

Just my penny.



More information about the Digitalmars-d mailing list