Suggestion: Remove implicit conversion from T[n] and T[] to T*

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Dec 2 08:27:55 PST 2006


"Tomas Lindquist Olsen" <tomas at famolsen.dk> wrote in message 
news:ekrhqi$7c0$1 at digitaldaemon.com...
>I think it should stay as-is for the sole reason that otherwise this
> wouldn't work:
>
> printf("hello world");
>

Waitwaitwait.. surely you mean:

writefln("hello world");

? ;)

See, I think the implicit conversion from char[] to char* exists only for 
this purpose -- for Walter to be able to write printf statements with string 
literals.  But the problem gets much worse when you're not using string 
literals -- i.e. you get access violations.  That, and does anyone know if 
it says _anywhere_ in the D spec that string literals are _required_ to be 
zero-terminated?  What if that "feature" (again, useful only for passing to 
C string handling functions) goes away, or if another compiler doesn't do 
it?

D's arrays (and its strings in particular) are not the same as C's.  Trying 
to make the conversion from D's to C's implicit only leads to confusion and 
bugs. 





More information about the Digitalmars-d mailing list