On Friday, 18 December 2015 at 22:35:04 UTC, anonymous wrote:
If the parameter is de facto const, then the cast is ok. Though, maybe it should be marked const then.

I'm just worried about casts because I read somewhere that strings start with the number of characters inside them (probably in slices documentation), and not with actual content (though string literals probably act different in this case).

Documentation on casts say:

Casting a pointer type to and from a class type is done as a type paint (i.e. a reinterpret cast).

Reinterpretation is rather dangerous if strings are stored differently.

But this test gives me a good hope on this case:

    writeln(*(cast(char*) "Test"));

Casting is what I'm going with. .dup.ptr is less clear in this case.

Reply via email to