[Proposal] Add module for C-strings support in Phobos
Adam D. Ruppe
destructionator at gmail.com
Fri Mar 21 13:06:18 PDT 2014
On Friday, 21 March 2014 at 19:59:51 UTC, angel wrote:
> Going slightly beyond a new module code, it might, possibly, be
> useful to enable zero-terminated string creation on the core
> language level, with:
> auto mystr = "hello"z;
The core language already knows zero-terminated strings:
void main() {
immutable(char)* s = "lol";
}
Regular 8-bit strings implicitly convert to pointers without
needing to explicitly call the .ptr property and they are always
zero terminated automatically.
This is why you can write printf("foo"); in D and have it just
work without complaining about needing toStringz.
You can also write:
const char* s = "lol";
and that works too. Not quite auto, but not a big hassle.
More information about the Digitalmars-d
mailing list