December 11, 2019
On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community Review for DIP 1027, "String Interpolation":
>
> https://github.com/dlang/DIPs/blob/148001a963f5d6e090bb6beef5caf9854372d0bc/DIPs/DIP1027.md
>
> All review-related feedback on and discussion of the DIP should occur in this thread. The review period will end at 11:59 PM ET on December 25, or when I make a post declaring it complete.
>
> At the end of Round 1, if further review is deemed necessary, the DIP will be scheduled for another round of Community Review. Otherwise, it will be queued for the Final Review and Formal Assessment.
>
> Anyone intending to post feedback in this thread is expected to be familiar with the reviewer guidelines:
>
> https://github.com/dlang/DIPs/blob/master/docs/guidelines-reviewers.md
>
> *Please stay on topic!*
>
> Thanks in advance to all who participate.

Nice but it sounds a bit "hacky" to me.

If i'm right this code will output "Hello %textworld123"

string text = "world";
text(i"Hello %text", "123");

I hoped it was expanded to a function call rather than to a tuple...


Andrea
December 11, 2019
On Wednesday, 11 December 2019 at 11:45:07 UTC, Andrea Fontana wrote:
> If i'm right this code will output "Hello %textworld123"


Oops, I mean "Hello %sworld123"
December 11, 2019
On Wednesday, 11 December 2019 at 11:05:25 UTC, Sebastiaan Koppe wrote:
> On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker wrote:
>> This is the feedback thread for the first round of Community Review for DIP 1027, "String Interpolation":
>>
>> https://github.com/dlang/DIPs/blob/148001a963f5d6e090bb6beef5caf9854372d0bc/DIPs/DIP1027.md
>
> Nice!
>
> I just have a few nitpicks:
>
> - I don't mind the required prefix 'i', but what about q{} strings? I probably want to use interpolation there as well
>
> - I know it is bikeshedding but since string interpolation is 99% syntax, I vote for "either a single $colon for variables or ${expression} for expressions", like literally every other modern language.
>
> Besides that, this is really nice.

Yes +1! It should be something common, not a dlang only syntax.
=> $var and ${expression}

https://en.wikipedia.org/wiki/String_interpolation

But this alone gives no way for formatting numbers, so maybe ${%9.6f}{fvar} ?
December 11, 2019
On Wednesday, 11 December 2019 at 11:40:44 UTC, Ola Fosheim Grøstad wrote:
> On Wednesday, 11 December 2019 at 11:21:08 UTC, Ola Fosheim Grøstad wrote:
>> log(f"I have {dec(3,2)}{account.total} USD in my pocket")
>>

Note: the above suggestion is close to Python 3.

https://docs.python.org/3/reference/lexical_analysis.html#formatted-string-literals

December 11, 2019
On Wednesday, 11 December 2019 at 11:45:07 UTC, Andrea Fontana wrote:
> On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker wrote:
>> This is the feedback thread for the first round of Community Review for DIP 1027, "String Interpolation":
>>
>> https://github.com/dlang/DIPs/blob/148001a963f5d6e090bb6beef5caf9854372d0bc/DIPs/DIP1027.md
>>
>> All review-related feedback on and discussion of the DIP should occur in this thread. The review period will end at 11:59 PM ET on December 25, or when I make a post declaring it complete.
>>
>> At the end of Round 1, if further review is deemed necessary, the DIP will be scheduled for another round of Community Review. Otherwise, it will be queued for the Final Review and Formal Assessment.
>>
>> Anyone intending to post feedback in this thread is expected to be familiar with the reviewer guidelines:
>>
>> https://github.com/dlang/DIPs/blob/master/docs/guidelines-reviewers.md
>>
>> *Please stay on topic!*
>>
>> Thanks in advance to all who participate.
>
> Nice but it sounds a bit "hacky" to me.
>
> If i'm right this code will output "Hello %textworld123"
>
> string text = "world";
> text(i"Hello %text", "123");
>
> I hoped it was expanded to a function call rather than to a tuple...
>
>
> Andrea

If my understanding is right, string assignment is not supported by the dip, only the 2 functions writeln/printf.
Which would be a quite big limitation. This would only cover 20% of my use case
of string interpolation.
Is my understanding correct?

Kind regards
André
December 11, 2019
On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community Review for DIP 1027, "String Interpolation":
>
> https://github.com/dlang/DIPs/blob/148001a963f5d6e090bb6beef5caf9854372d0bc/DIPs/DIP1027.md
>
> writefln(i"I ate %apples and %{d}bananas")

What if I don't want any space after %apples?


December 11, 2019
On 12/11/19 2:35 PM, rumbu wrote:
> Nope, that means "use %d format specifier to print number of bananas". According to the DIP, this is invalid:
> 
> string what = "bread";
> int d = 10;
> writefln(i"making %what using %d ingredients");
> 

According to the DIP this is valid. It would be interpreted as
writefln("making %s using %s ingredients", what, d);
December 11, 2019
On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community Review for DIP 1027, "String Interpolation":
>
> https://github.com/dlang/DIPs/blob/148001a963f5d6e090bb6beef5caf9854372d0bc/DIPs/DIP1027.md
>
> All review-related feedback on and discussion of the DIP should occur in this thread. The review period will end at 11:59 PM ET on December 25, or when I make a post declaring it complete.
>
> At the end of Round 1, if further review is deemed necessary, the DIP will be scheduled for another round of Community Review. Otherwise, it will be queued for the Final Review and Formal Assessment.
>
> Anyone intending to post feedback in this thread is expected to be familiar with the reviewer guidelines:
>
> https://github.com/dlang/DIPs/blob/master/docs/guidelines-reviewers.md
>
> *Please stay on topic!*
>
> Thanks in advance to all who participate.

From the dip it seems that it is only valid for writefln & co
So a code like:
   auto myText = i"I ate% apples"
would not be valid.

Correct me if I'm wrong but from my point of view this "String interpolation" is completely useless.
I wish D had a string interpolation like Kotlin
December 11, 2019
On Wednesday, 11 December 2019 at 11:45:07 UTC, Andrea Fontana wrote:
> I hoped it was expanded to a function call rather than to a tuple...

Or maybe some kind of formatting-objects protocol? Then you could things like:

f" …%1.3f{some_float}…{otherstuff}"

=>

(
"…",
 string_format_f!typeof(some_float)(1,3)(some_float),
"…",
otherstuff
)

*shrugs*
December 11, 2019
On Wednesday, 11 December 2019 at 09:52:21 UTC, Mike Parker wrote:
> This is the feedback thread for the first round of Community Review for DIP 1027, "String Interpolation":
>
> https://github.com/dlang/DIPs/blob/148001a963f5d6e090bb6beef5caf9854372d0bc/DIPs/DIP1027.md

What happens in a template?

---
string str = "work";
template myTemplate(string str, Args...) {}

myTemplate!(i"will this %str as expected?");
---

How will the params be passed? Aliased?