const challenge

Janice Caron caron800 at googlemail.com
Sat Feb 2 23:44:03 PST 2008


On 2/2/08, Derek Parnell <derek at psych.ward> wrote:
> void main()
> {
>     string s;
>     char[] t;
>     char[] u = "hello" ~ s ~ t;
>
>     writefln("%s", u);
> }
> c:\temp>dmd test
> c:\dmd\dmd\bin\..\..\dm\bin\link.exe test,,,user32+kernel32/noi;
>
> c:\temp>test
> hello

Bah! Dangnabbit! OK then - /this/ doesn't compile:

>     string s;
>     char[] t;
>     string u = "hello" ~ s ~ t;

I'm fairly sure that the char[] version didn't compile in some earlier
version of D, but I'm not going to redownload the old versions to find
out. In any case the string version doesn't compile, and that's just
as bad. The error message indicates that the compiler can't convert a
char[] to an invariant(char)[], which means that the type of the RHS
is now deemed to be char[]. (In previous releases, I'm sure it would
have been const(char)[], but I see nothing in the change log to
account for it. Maybe it's I who's going mad?)



More information about the Digitalmars-d mailing list