Idea: Introduce zero-terminated string specifier
Steven Schveighoffer
schveiguy at yahoo.com
Tue Oct 2 13:44:11 PDT 2012
On Tue, 02 Oct 2012 15:35:47 -0400, David Nadlinger <see at klickverbot.at>
wrote:
> On Tuesday, 2 October 2012 at 19:34:31 UTC, David Nadlinger wrote:
>> Well, make it to!char(char*) then! ;)
>
> Oh dear, this doesn't get better: Of course, I've meant to write
> »to!(char[])(char*)«.
Right. I agree, this should not allocate (I think someone said it does,
but it's probably not necessary to).
But still, what looks better?
auto x = SomeSystemCallThatReturnsACString();
writefln("%s", to!(char[])(x));
writefln("%s", zstr(x));
I want something easy to type, and not too difficult to visually parse.
In fact, a better solution would be to define a C string type (other than
char *), and just pretend those system calls return that. Then support
that C string type in writef.
-Steve
More information about the Digitalmars-d
mailing list