<div class="gmail_quote">On Wed, May 16, 2012 at 5:25 PM, Steven Schveighoffer <span dir="ltr"><<a href="mailto:schveiguy@yahoo.com" target="_blank">schveiguy@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Tue, 15 May 2012 18:31:26 -0400, deadalnix <<a href="mailto:deadalnix@gmail.com" target="_blank">deadalnix@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Le 15/05/2012 17:51, Christophe a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
deadalnix , dans le message (digitalmars.D:167404), a écrit :<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This looks to me like a bad practice. C string and D string are<br>
different beasts, and we have toStringz .<br>
</blockquote>
<br>
C string and D string are different, but it's not a bad idea to have<br>
string *literals* that works for both C and D strings, otherwise using<br>
printf will lead to a bug each time the programmer forget the trailing<br>
\0.<br>
<br>
</blockquote>
<br>
Due to slicing, it is already unsafe to pass a D string to C code. The main problem is array casting silently to pointers, making the error easy to do.<br>
</blockquote>
<br></div>
How so?  strings are immutable, and literals are *truly* immutable.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Fixing the problem for literal isn't going to solve it at all.<br>
<br>
The real solution is toStringz<br>
</blockquote>
<br></div>
toStringz can allocate a new block in order to ensure 0 gets added.  This is ludicrous!<br>
<br>
You are trying to tell me that any time I want to call a C function with a string literal, I have to first heap-allocate it, even though I *know* it's safe.<br>
<br>
I don't see a "problem" anywhere.  The current system is perfect for what it needs to do.<br>
<br>
-Steve<br>
</blockquote></div><br>Aside from the string problem the very existence of this debate exposes a fundamental flaw in the entire software engineering industry: heavy usage of ancient crap.<div>If some library is so damned hard to refresh, then something's terribly wrong with it. It's about damned time ancient libraries are thrown away.</div>
<div><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>