[Issue 6232] An idea for std.string.toStringz docs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jun 30 18:33:26 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6232



--- Comment #3 from Jonathan M Davis <jmdavisProg at gmx.com> 2011-06-30 18:28:29 PDT ---
Your suggestion doesn't help at all with remembering to use zero-terminated
strings when calling C code. For that you have to remember that you need to do
that and that toStringz is the function to use to get a zero-terminated string.
Adding your example to toStringz's documenation wouldn't help anyone remember
to use it.

If anything is wrong with the type system, it's the fact that it implicitly
converts arrays to pointers, but even if it required you to use the ptr
property instead, people would still have to remember to use toStringz for
strings. So, such a change to type system wouldn't help any. Are your
suggestion only helps as far as the type system goes if all of the C functions
in druntime or wherever use CcharPtr instead of char*, since if the function
takes char*, you can still pass a string directly to them even if you have
CcharPtr to use if you want to. So, I don't see how this suggestion helps much
of anything.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list