DIP 1027---String Interpolation---Community Review Round 1
Patrick Schluter
Patrick.Schluter at bbox.fr
Mon Dec 16 11:18:33 UTC 2019
On Monday, 16 December 2019 at 11:08:00 UTC, Patrick Schluter
wrote:
> On Monday, 16 December 2019 at 10:48:51 UTC, aliak wrote:
>
>> Resolving interpolation at compile time is imho incompatible
> with handling them as regular strings.
Maybe I'm wrong here, I haven't thought it through, but in first
approach I think that's an essential point. As the string
contains code, if evaluated at CT, the string must be split
somehow in literal parts and code parts. Allowing the i-string to
be handled as regular string implies that the splitting happens
sometime between when it is declared and after it is used, which
can happen after runtime.
import fn;
int b = 20;
string inter = i"$(a+b)";
foreach(a; 1..10)
fn(inter);
---
module fn;
void fn(string s)
{
writefln(s);
}
How would that work?
In python or javascript there's no issue, a is a runtime symbol.
>
> The question is then do we want CT or RT interpolated strings.
> RT interpolated strings can still be provided by a library.
More information about the Digitalmars-d
mailing list