Stepping back and looking at constness from another angle.

Carlos Santander csantander619 at gmail.com
Tue Jun 5 19:15:59 PDT 2007


Sean Kelly escribió:
> 
> The proposed changes are actually pretty decent from a conceptual 
> standpoint but I don't like the syntax.  Using three synonyms to 
> represent different facets of const behavior kind of stinks.  I'm sure 
> I'll get used to it with practice, but I worry that the const features 
> will hurt readability for those new to the language, and will complicate 
> code in the general case for little actual gain.
> 

Not only for those new to the language, but for less experienced programmers too.

I know some C++, but I've never done anything serious with it. Thus, since I 
don't use it, I don't know what all those "const" do (once I read about it in 
some manual or something, but I no longer remember.) So, while I understand the 
problem at hand here, I still get confused over the syntax, even if I'm not new 
to the language, there have been so many discussions about that problem here, 
and the syntax has been explained so many times.

For example, yesterday Walter posted a message that included this line:

invariant(char)[new] ret = "prefix";

I understand it as "ret can't change." However, later on, on the same snippet, 
he appended to "ret." Not to mention that when I first read it, I had no idea 
what it was. I still don't know why those () are there and not somewhere else. 
Please don't try to explain to me; I guess it'll be clear once I start using it, 
but right now, I'm just trusting those who have walked this road before.

Finally, I wouldn't know how to explain it to someone who's just starting in 
programming. Again, maybe it's because I myself don't understand it, but bear 
with me for a moment. I don't think it'll be immediately crystal clear for 
everyone that in an array you can or can't change the length, the pointer, the 
contents, all of them, none of them, or some of them, and that the keyword you 
use is the one that defines that, that the keywords available are very close in 
meaning, and that using or not using parentheses also changes the meaning.

I'm sorry if it sounded over-dramatical; it certainly wasn't my intention. 
Bottom line is, I'm really hoping that it turns out well, and that I can 
understand it when it's out.

-- 
Carlos Santander Bernal



More information about the Digitalmars-d mailing list