Compile time strings auto concatenation!?
Justin Whear via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Nov 20 12:55:29 PST 2015
On Fri, 20 Nov 2015 20:39:57 +0000, Ilya wrote:
> Can DMD frontend optimize
> string concatenation
> ```
> enum Double(S) = S ~ S;
>
> assert(condition, "Text " ~ Double!"+" ~ ___FUNCTION__);
> ```
>
> to
>
> ```
> assert(condition, "Text ++_function_name_");
>
> ```
> ?
Yes this occurs as part of the constant folding I believe.
$ cat test.d
enum Double(string S) = S ~ S;
void main(string[] args){
assert(args.length, "Text " ~ Double!"+" ~ __FUNCTION__);
}
$ dmd test.d
$ strings test | grep Text
Text ++test.main
More information about the Digitalmars-d-learn
mailing list