On Tue, 02 Oct 2012 04:09:43 -0400, Walter Bright
<newshou...@digitalmars.com> wrote:
On 10/1/2012 7:22 PM, Steven Schveighoffer wrote:
Does it make sense for Phobos to provide such a shortcut in an obscure
header somewhere? Like std.cstring? Or should we just say "roll your own
if you need it"?
As a matter of principle, I really don't like gobs of Phobos functions
that are literally one liners. Phobos should not become a mile wide but
inch deep library of trivia. It should consist of non-trivial, useful,
and relatively deep functions.
This, arguably, is one of the most important aspects of C to support.
There are lots of C functions which provide C strings. Yes, we don't want
to promote using C strings, but to have one point of conversion so you
*can* use safe strings is a good thing. In other words, the sooner you
convert your zero-terminated strings to char slices, the better off you
are. And if we label it system code, it can't be misused in @safe code.
Why support zero-terminated strings as literals if it wasn't important?
You could argue that things like system calls which return zero-terminated
strings are as safe to use as string literals which you know have zero
terminated values.
The only other alternative is to wrap those C functions with D ones that
convert to char[]. I don't find this any more appealing.
-Steve