On Wednesday, 19 April 2017 at 15:07:55 UTC, Jonas Drewsen wrote:
I'm talking about building format strings just yet... I'm just
working with the suggestion that Walter brought up with
converting the interpolated string into something that can be
fed into format e.g.:
$"The date is {%04d year} and {user} just logged into {here}"
is rewritten by the compiler to:
"The date is %04d and %s just logged into %s", year, user, here
which can be fed into for example format(). Not sure I like the
need to call format to get the resulting string, but just
working with the idea here.
I also think it would loose a lot of value to only allow
strings as you suggest (e.g. %dateString).
If we had language-level tuple literals you could desugar the
expression into:
("The date is %04d and %s just logged into %s", year, user, here)
And let a user do whatever they want with it.
Even now it can be done with an AliasSeq, but not with the
automatic insertion of format arguments, of course.
alias fs = AliasSeq!("The date is %04d and %s just logged into
%s", 1992, "Alan", "10.1.0.123");
writeln(format(fs)); //Prints "The date is 1992 and Alan just
logged into 10.1.0.123"