String Interpolation

duckchess duckchess at chess.com
Mon Oct 30 19:32:36 UTC 2023


On Monday, 30 October 2023 at 15:53:26 UTC, bachmeier wrote:
> On Monday, 30 October 2023 at 15:19:01 UTC, duckchess wrote:
>
>> and no, there's no need for other languages to change, as they 
>> have string interpolation. they don't have what the proposals 
>> for D are.
>
> It's more accurate to say that is that the only proposals that 
> will get serious consideration are the ones that redefine the 
> term "string interpolation". Certainly many around here have 
> proposed that we have string interpolation in the usual sense 
> of the term.

you are not wrong. but at the same time there's good reason for 
it too.
the problem i have with built in string interpolation is, it's 
unflexible. that's why i'd rather see macros implemented in the 
language, but there's even more people against that, including 
walter.
but there's no way to have all options at once.

built in string interpolation:
  + simple syntax for strings.
  - unflexible for more than basic use cases.
macros:
  + super flexible.
  - has the problem macros have, like capturing everything.
adams proposal:
  + almost every use case is covered.
  + you can get an interpolated string with something like s!i"".
  - not what a normal user might expect, and slighly more verbose.
Walters DIP:
  - no flexible
  - super dangerous to use

that's why i wouldn't even use i"" as syntax, but t"" to make it 
extra clear that it'S not string interpolation like in other 
languages.


More information about the Digitalmars-d mailing list