The state of string interpolation...one year later

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 18 16:48:59 UTC 2019


On Mon, Mar 18, 2019 at 04:30:26PM +0000, Meta via Digitalmars-d wrote:
> On Monday, 18 March 2019 at 09:07:26 UTC, Olivier FAURE wrote:
> > On Sunday, 17 March 2019 at 06:01:35 UTC, Jonathan Marler wrote:
> > > https://github.com/dlang/dmd/pull/7988
> > 
> > By the way, quick question, how does the PR handle this case?
> > 
> >     i"$a $b" ~ i$"c $d"
> 
> Also, recursive use of interpolated strings. Does this work or fail
> with a compiler error like "can't find symbol c":
> 
> int a = 2, b = 5;
> enum code = text(i"mixin(\"int c = $(a + b)\"); writeln(i\"a = $a, b =
> $b, c = $c\");");
> mixin(code);
[...]

I'd expect you'd have to escape the $ in the nested interpolated string.
I forgot what the escape was, perhaps `$$`?


T

-- 
Tell me and I forget. Teach me and I remember. Involve me and I understand. -- Benjamin Franklin


More information about the Digitalmars-d mailing list