On Wed, 16 May 2012 17:06:41 -0400, Alex Rønne Petersen <[email protected]> wrote:

On 16-05-2012 22:42, Steven Schveighoffer wrote:
On Wed, 16 May 2012 16:19:36 -0400, Alex Rønne Petersen <[email protected]>
wrote:

Theoretically, yes, practically, not really.

void myLog(string msg)
{
printf(msg);
}

Wait, this should be an error. You need toStringz there.

-Steve

Sorry, I meant:

void myLog(string msg)
{
     printf(msg.ptr);
}

(Which works as expected because string literals are null-terminated. This is also how things work when you pass a string literal to a const(char)* value; it just does "literal".ptr.)

No, it doesn't:

myLog("abc"[0..1]); // prints abc instead of the requested a

string is not necessarily a literal. A literal has a special polysemous type, and special properties. An ordinary string does not.

-Steve

Reply via email to