Kill implicit joining of adjacent strings

Michel Fortin michel.fortin at michelf.com
Thu Nov 11 05:06:41 PST 2010


On 2010-11-10 23:51:38 -0500, Rainer Deyke <rainerd at eldwood.com> said:

> As it turns out, the joining of adjacent strings is a critical feature.
>  Consider the following:
>   f("a" "b");
>   f("a" ~ "b");
> These are /not/ equivalent.  In the former cases, 'f' receives a string
> literal as argument, which means that the string is guaranteed to be
> zero terminated.  In the latter case, 'f' receives an expression (which
> can be evaluated at compile time) as argument, so the string may not be
> zero terminated.  This is a critical difference if 'f' is a (wrapper
> around a) C function.

You worry too much. With 'f' a wrapper around a C function that takes a 
const(char)* argument, if the argument is not a literal string then it 
won't compile. Only string literals are implicitly convertible to 
const(char)*, not 'string' variables.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/



More information about the Digitalmars-d mailing list