An Invariant WTH?

Jarrett Billingsley kb3ctd2 at yahoo.com
Sun Nov 4 16:44:01 PST 2007


"Chad J" <gamerChad at _spamIsBad_gmail.com> wrote in message 
news:fglnam$eh8$1 at digitalmars.com...
> import std.stdio;
>
> void main()
> {
>   char[] hello = "Hello world!";
>   writefln( hello );
> }
>
> ----------------------
>
> main.d(5): Error: cannot implicitly convert expression ("Hello world!") of 
> type invariant char[12u] to char[]
>
> ----------------------
>
> I know that `string hello = "Hello World!";` would cause the desired 
> results, but this makes me have to learn all about constness and 
> invariance just to make very trivial programs.  More learning curve = BAD. 
> Also, if I wanted to do an inplace toLower or somesuch on the "Hello 
> World!" string, then things get more complicated than in 1.0.
>
> It also disturbs me that "string" is just one of "wstring" and "dstring", 
> and not a more useful generic string type like the dstring that Chris 
> Miller wrote.
>
> Not to mention the massive drain on D community's and Walter's resources 
> that this has caused.
>
> D2.0 just got closures, and I still get the feeling that I don't like 
> const.  So I'm wondering if it is irrational to have this feeling that I'm 
> getting some sort of ugly const thing shoved down my throat.
>
> Bitching and moaning aside, there's got to be a reason we are doing this 
> const thing.  Something good.  Something besides "C/C++ needed it to be 
> less buggy" - C and C++ tend to need a lot of bug fighting measures in 
> places that D conveniently doesn't really need much help in.  Also, 
> something besides "it'll make your program 1% faster".  I was not 
> convinced by those.
>
> It's all cost-benefit.  I'm seeing a lot of cost with little or dubious 
> benefit.  So why should I be convinced that this is the right thing to do? 
> Why should I be willing to write D2.0 code?

You're not alone in feeling this way. 




More information about the Digitalmars-d-learn mailing list