Compile time strings auto concatenation!?

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 21 06:33:16 PST 2015


On Friday, 20 November 2015 at 20:39:58 UTC, Ilya wrote:
> Can DMD frontend optimize
>  string concatenation
> ```
> enum Double(S) = S ~ S;
>
> assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__);
> ```
>
> to
>
> ```
> assert(condition, "Text ++_function_name_");
>
> ```
> ?

At least for string (and array?) literals, it's now guaranteed to 
happen at compile time. It was changed in order to get rid of the 
error-prone "concatenation by juxtaposition" feature inherited 
from C. I'm not sure it also applies to non-literals, though.


More information about the Digitalmars-d-learn mailing list