Interpolated strings
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 21 07:17:11 PDT 2017
On Thursday, 20 April 2017 at 19:02:20 UTC, Kagamin wrote:
> Also how various kinds of strings would work?
> r$"{can}\i\has{slashes}"
> $`same {here}`
r"" and `` are WysiwygStrings. Interpolation is not WYSIWYG.
$"" would need to support escaping of the interpolation start
character, so may as well escape with backslash like "" strings.
> $q{{balanced}braces}
q{} strings have to lex correctly, so are intended for code -
brace interpolation would play badly with braces in code. It
might be useful with mixins if using a different interpolation
syntax, e.g. $identifier or ${var+1} syntax within the string:
void fun(string op)(T a, T b){
mixin(text($q{$a $op= $b;}));
}
(I used `text` for Dmitry's AliasSeq expansion - use `format` for
Walter's).
More information about the Digitalmars-d
mailing list