template statistics
Steven Schveighoffer
schveiguy at gmail.com
Wed Jun 3 21:01:48 UTC 2020
On 6/3/20 3:59 PM, Walter Bright wrote:
> On 6/3/2020 1:06 AM, Nick Treleaven wrote:
>> How does writeln tell that a zero terminated string has been passed?
>
> D string literals always have a 0 terminator.
All compile-time strings should be both 0 terminated and implicitly
convertible to immutable(char)*. I think there are some cases that
aren't, but I don't remember all of them.
But the question above is still unanswered -- writeln receives a string
as an immutable(char)[], and doesn't know that it's from a literal.
For example, if writeln blindly assumed that all immutable(char)[] were
string literals, that it could pass to puts, this would be a problem:
writeln(somestr.idup);
-Steve
More information about the Digitalmars-d
mailing list