On Tuesday, 18 April 2017 at 08:50:07 UTC, Walter Bright wrote:
It may not be necessary to have any dependencies on any import.

    $"{a} times 3 is {a*3}"

could be rewritten by the parser to:

    "%s times 3 is %s", a, a * 3

and that is that. (I.e. just an AST rewrite.) It would be quite a bit simpler than Jonas' proposed implementation.

For, say, sql query generator it would be nice to have a rewrite like
sql!"select name from users where id={n}"
=>
auto q=query("select name from users where id=@p0");
q.addParameter("p0",n);

pragma(autoMixin)
template sql(string txt)
{
  enum string sql=generateCode(txt);
}

If this can be rewritten as automatic string mixin like so:
sql!"select name from users where id={n}"
=>
mixin(sql!"select name from users where id={n}")

Reply via email to