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.

Reply via email to