<div dir="ltr"><div>the proposed new syntax</div><div>r{var1=@a; and var2=@foo}<br></div><div><br></div><div>is replaced by a tuple:</div><div>("var1=", a, "; and var2=", foo)</div><div>where @ denotes escaping symbols.<br>
</div><div><br></div><div>@ itself be escaped with \@.<br></div><div><br></div><div>optionally, expressions can be incorporated:</div><div><div>r{a2=@(a*2); and fooU=@(foo.toUpper)}<br></div></div><div><br></div><div>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). <br>
</div><div><br></div><div>Proper tooling will syntax highlight correctly the nested variables.</div><div><br></div><div><br></div><div><div>This feature is especially useful when there are a few variables involved, as alternatives are clunky</div>
</div><div><br></div><div><br></div><div>use cases:<br></div><div>A) simple string formatting (eg: formattedWrite)</div><div>----</div><div>q{first var=@a, second=@b, third=@c!}.foo</div><div>vs:</div><div>("first var=",a," second=",b," third=",c,"!").foo // `",,"` for a single `@`</div>
<div>("first var=%s, second=%s, third=%s!", a, b, c).foo => // error prone esp with many variables</div><div>or alternatives involving ~ :<br></div><div>("first var="~<a href="http://a.to">a.to</a>!string~", second="~<a href="http://b.to">b.to</a>!string~", third="~<a href="http://c.to">c.to</a>!string~"!").foo //clunky<br>
</div><div><div><br></div></div><div>B) parsing (eg formattedRead)<br></div><div>same advantages as above</div><div><br></div><div><br></div></div>