On Saturday, 14 October 2023 at 14:47:26 UTC, Andrey Zherikov wrote:
>Why does not this work for you?
string s = text("Hello ",name,", you are ",age," years old and have ",money - 42," dollars in the bank");
Check the first post.
October 14, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrey Zherikov | On Saturday, 14 October 2023 at 14:47:26 UTC, Andrey Zherikov wrote: >Why does not this work for you?
Check the first post. |
October 15, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On Saturday, 14 October 2023 at 20:05:42 UTC, Andrea Fontana wrote: >On Saturday, 14 October 2023 at 14:47:26 UTC, Andrey Zherikov wrote: >Why does not this work for you?
Check the first post. I would actually be fine with smith like interp!"Hello {name}, your name is {name} and you have {money -42} dollars in the bank" until he have a character to use for it |
October 15, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Sunday, 15 October 2023 at 07:10:06 UTC, Imperatorn wrote: >On Saturday, 14 October 2023 at 20:05:42 UTC, Andrea Fontana wrote: >On Saturday, 14 October 2023 at 14:47:26 UTC, Andrey Zherikov wrote: >Why does not this work for you?
Check the first post. I would actually be fine with smith like interp!"Hello {name}, your name is {name} and you have {money -42} dollars in the bank" until he have a character to use for it Typo but you get the point 😅 |
October 15, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Imperatorn | On Sunday, 15 October 2023 at 07:10:39 UTC, Imperatorn wrote: >On Sunday, 15 October 2023 at 07:10:06 UTC, Imperatorn wrote: >On Saturday, 14 October 2023 at 20:05:42 UTC, Andrea Fontana wrote: >On Saturday, 14 October 2023 at 14:47:26 UTC, Andrey Zherikov wrote: >Why does not this work for you?
Check the first post. I would actually be fine with smith like interp!"Hello {name}, your name is {name} and you have {money -42} dollars in the bank" until he have a character to use for it Typo but you get the point 😅 Yes these versions are fine too i"hello ${world+1} $another_var" or: """hello ${word+1} $another_var""" or: $"hello ${world+1} $another_var" or: "hello %{world+1} %another_var"! or whatever enables string interpolation :) |
October 15, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On Sunday, 15 October 2023 at 08:18:04 UTC, Andrea Fontana wrote: >On Sunday, 15 October 2023 at 07:10:39 UTC, Imperatorn wrote: >On Sunday, 15 October 2023 at 07:10:06 UTC, Imperatorn wrote: >On Saturday, 14 October 2023 at 20:05:42 UTC, Andrea Fontana wrote: >On Saturday, 14 October 2023 at 14:47:26 UTC, Andrey Zherikov wrote: >[...] Check the first post. I would actually be fine with smith like interp!"Hello {name}, your name is {name} and you have {money -42} dollars in the bank" until he have a character to use for it Typo but you get the point 😅 Yes these versions are fine too i"hello ${world+1} $another_var" or: """hello ${word+1} $another_var""" or: $"hello ${world+1} $another_var" or: "hello %{world+1} %another_var"! or whatever enables string interpolation :) Agreed! |
October 17, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md |
October 17, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrea Fontana | On 10/12/2023 6:39 AM, Andrea Fontana wrote: > ``` > stderr.write("${clear}\r{$white}Progress:${clear}${progress}% \t${white}Speed:${clear} ${curSpeed} ${unit}"); > ``` With DIP1027: ``` stderr.write("$clear\r$(white)Progress:$clear$progress% \t$(white)Speed:$clear $curSpeed $unit"); ``` If it's a simple identifier, the { } are not necessary. https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md#description |
October 17, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 10/17/2023 10:24 AM, Walter Bright wrote: > ``` > stderr.write("$clear\r$(white)Progress:$clear$progress% > \t$(white)Speed:$clear $curSpeed $unit"); > ``` Oops, forgot the leading 'i': ``` stderr.write(i"$clear\r$(white)Progress:$clear$progress% \t$(white)Speed:$clear $curSpeed $unit"); ``` |
October 17, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Tuesday, 17 October 2023 at 17:27:41 UTC, Walter Bright wrote: > Oops, forgot the leading 'i': > > ``` > stderr.write(i"$clear\r$(white)Progress:$clear$progress% > \t$(white)Speed:$clear $curSpeed $unit"); > ``` Still won't work. Your dip1027 would write %s\r%sProgress:%s%s%\t%sSpeed:%s %s %s\e[09m\e01m5\[30m\0[09m5bytes/sec if you used it like that. This is one of the reasons why it was rejected. If we want to move forward, there's actually a good proposal out there: https://github.com/John-Colvin/YAIDIP |
October 17, 2023 Re: Just another example of missing string interpolation | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D Ruppe | On 10/17/2023 10:37 AM, Adam D Ruppe wrote:
> On Tuesday, 17 October 2023 at 17:27:41 UTC, Walter Bright wrote:
>> Oops, forgot the leading 'i':
>>
>> ```
>> stderr.write(i"$clear\r$(white)Progress:$clear$progress%
>> \t$(white)Speed:$clear $curSpeed $unit");
>> ```
>
> Still won't work. Your dip1027 would write
>
> %s\r%sProgress:%s%s%\t%sSpeed:%s %s %s\e[09m\e01m5\[30m\0[09m5bytes/sec
>
> if you used it like that.
That's a misunderstanding of how it works.
|