Dynamic Template-Expansion of (Token) Strings
Per Nordlöw
per.nordlow at gmail.com
Tue Oct 27 08:33:08 UTC 2020
I'm looking for elegant ways of expressing expansion of
parameterized strings written to a file at run-time. My primary
use case is run-time generation of D code. In the lazy case,
something like
import std.file : write;
import std.algorithm : substitute;
const s = q{int $X = $Y;}; // templated source
foreach (part; s.substitute("$X", "x", "$Y", "42"))
write(somePath, part);
is my current best bet.
More information about the Digitalmars-d-learn
mailing list