We are forking D

Timon Gehr timon.gehr at gmx.ch
Sun Jan 7 23:45:14 UTC 2024


On 1/7/24 21:19, Walter Bright wrote:
> On 1/7/2024 11:52 AM, brianush1 wrote:
>> Not arsd.sqlite, nor any other library, defines their own interpolated 
>> strings. Importing a library does not and cannot change the behavior 
>> of interpolated strings, that is a misunderstanding. Library functions 
>> simple take in the interpolated string using a vararg template and do 
>> literally *whatever they want with it,* since they're given all the 
>> information about the interpolated string, including the evaluated 
>> expressions that were inside the string.
> 
> Thanks for the clarification. I had indeed misunderstood it.
> 
> So that means db.execi() is the template that adjusts how the call to 
> sql is made. (I had assumed it was part of the sql api, rather than a 
> wrapper.)
> 
> This makes it no different than DIP1027 in that regard.
> 
> It is not really necessary to have a marker to say if an argument is a 
> literal or a variable. Consider this program:
> 
> ```
> import std.stdio;
> 
> void main()
> {
>      writeln("hello".stringof);
>      string foo = "betty";
>      writeln(foo.stringof);
> }
> ```
> 
> Which, when run, prints:
> 
> "hello"
> foo
> 
> and so a template, by using .stringof, can determine if a tuple element 
> is a string literal or a variable.

Only if you pass the i-string as a template parameter (which might not 
even work because any non-symbol expression will need to be evaluated at 
compile time but maybe cannot). DIP1036 does not require that.

Also, what do you do if someone nests multiple i-strings? DIP1036 
handles it. etc. The design is simple but it addresses many issues that 
authors of competing proposals did not even think about.


More information about the Digitalmars-d mailing list