The state of string interpolation
Steven Schveighoffer
schveiguy at gmail.com
Thu Dec 6 19:58:43 UTC 2018
On 12/6/18 2:27 PM, Steven Schveighoffer wrote:
> The more I think about it, the better it is to use the original
> proposal, and just pass the parameters at compile time in order to make
> it work. The non-string portions will be aliases to the expressions or
> variables, making them easily distinguishable from the string portions.
>
> So instead of my original db.exec(...), you'd do db.exec!(...), exactly
> the same as before, just it's passed at compile time vs. runtime. The
> runtime possibility is there too, but you wouldn't use it in a database
> setting.
>
> This can be used to forward to whatever you want. If you want to change
> the parameters to FromInterpolation("foo", foo), it will be possible.
e.g. (need some support here, from new __traits):
foo(StringInterp...)()
{
auto makeInterpolation(alias x)()
{
static if(isCompileTimeString!x) return x;
else return FromInterpolation!(__traits(interpolationOf, x))(x);
}
return fooImpl(staticMap!(makeInterpolation, StringInterp));
}
-Steve
More information about the Digitalmars-d
mailing list