The state of string interpolation...one year later
kinke
noone at nowhere.com
Sun Mar 17 23:21:55 UTC 2019
I like the idea and find the tuple approach very elegant.
On Sunday, 17 March 2019 at 14:01:36 UTC, ag0aep6g wrote:
> void writeflnToHTML(S ...)(string f, S stuff)
> {
> writefln(f, tupleMap!toHTML(stuff).expand);
> }
> writeflnToHTML(`<html><body>
> <title>%s</title>
> <name>%s</name><age>%s</age>
> <a href="%s">%s</a>
> </body></html>
> `, title, name, age, link, linkName);
>
> That's still not pretty at all, but we can't forget a `.toHTML`
> this way. (Though `tupleMap` isn't in phobos and might be hard
> to get exactly right.)
>
> Ideally, something like that would be possible with
> interpolated strings, too.
As long as the embedded expressions are always separated by a
string literal in the resulting tuple, incl. an empty one
(`i"$(a)$(b)"` => `"", a, "", b`), these embedded expressions can
be identified (and appropriately transformed etc.) by an odd
index.
More information about the Digitalmars-d
mailing list