the proposed new syntax
r{var1=@a; and var2=@foo}
is replaced by a tuple:
("var1=", a, "; and var2=", foo)
where @ denotes escaping symbols.
@ itself be escaped with \@.
optionally, expressions can be incorporated:
r{a2=@(a*2); and fooU=@(foo.toUpper)}
I've actually already implemented this feature via a mixin, and find it extremely useful, but removing the mixing via this proposal would make it even more palatable. It works using a simple grammar that searches for valid identifiers after a @, or finds nested expressions nested inside parenthesis (arbitrary nesting allowed).
Proper tooling will syntax highlight correctly the nested variables.
This feature is especially useful when there are a few variables involved, as alternatives are clunky
use cases:
A) simple string formatting (eg: formattedWrite)
----
q{first var=@a, second=@b, third=@c!}.foo
vs:
("first var=",a," second=",b," third=",c,"!").foo // `",,"` for a single `@`
("first var=%s, second=%s, third=%s!", a, b, c).foo => // error prone esp with many variables
or alternatives involving ~ :
("first var="~
a.to!string~", second="~
b.to!string~", third="~
c.to!string~"!").foo //clunky
B) parsing (eg formattedRead)
same advantages as above