On Sun, 11 Apr 2010 15:33:09 -0400, Ali Çehreli <[email protected]> wrote:

This is a bug, right? I've been assuming that unqualified string literals were immutable char arrays, but the behavior is different between "hello" vs. "hello"c.

Am I missing something?

"hello" is typed as a string *only* if you are using at a string. If you are using it as a wstring or a dstring, then it is typed that way. You can even use it as a const(char) * and it becomes an ASCII C-style string with a zero terminator!

This way, you can do things like this without casts, conversions, or suffixes:

dstring ds = "hello";

Unfortunately, this leads to the problem, what version of foo to call when supplied with just a literal? It can call all three!

I don't like the implementation -- give an error -- but it's not an unreasonable choice. I'd file a bug and see what happens, perhaps Walter can change it. I'd recommend assuming the type that occurs when using auto.

-Steve

Reply via email to