Discussion Thread: DIP 1036--String Interpolation Tuple Literals--Community Review Round 2
sighoya
sighoya at gmail.com
Thu Feb 4 18:39:58 UTC 2021
I feel it mentally easier to treat them as strings at compile
time, too.
Can someone convince me why we are required to use tuples for
compile time interpolations?
Is it owed to defer the process of interpolation after template
expansion s.t. interpolation refers to the context inside the
template instead of outside:
```
someTemplate!(i"${Hello}${World}")() //$Hello and $World will be
substituted inside someTemplate
```
Can't we alternatively introduce another kind of string operator
allowing us to defer string interpolation up to the considered
place of substitution via the use of some closure?:
```
void someInterpolateFun(string function(string,string)
intermediate)
{
string s1=...
string s2=...
return intermediate(s1,s2)
}
string function(string Hello,string World) intermediate =
di"${Hello}${World}" //di stand for delegate/defer + interpolate
and creates a closure delegating the parameters into the
interpolation.
someInterpolateFun(intermediate)
```
More information about the Digitalmars-d
mailing list