Tuples, CTFE, and Sliding Template Arguments

Daniel N no at public.email
Sun Jan 14 09:41:16 UTC 2024


On Sunday, 14 January 2024 at 03:09:23 UTC, Jonathan M Davis 
wrote:
>
> To be honest, this is the only part of the string interpolation 
> proposals that seems even vaguely desirable to me. I absolutely 
> hate their syntax in comparison to just calling format. IMHO, 
> it's extremely hard to read strings with variables put into the 
> middle of them, whereas format allows you to see the string's 
> contents with minimal interference from what's going to be 
> inserted into it (and when the interference is greater, it's 
> because you're doing something fancier than %s, and you need to 
> be doing something that you're not gonig to be doing with 
> string interpolation anwyay). Obviously, that's a very 
> subjective thing, but given that I hate the syntax, string 
> interpolation would need to provide an actual technical benefit 
> for it to have any value for me.
>

I kinda agree, although I consider $variable to be more readable 
than format.

1) "$a $b $c" (DIP1027)
2) "%s %s %s".format(a, b, c)
3) "${a} ${b} ${c}" (DIP1036) Too much punctuation noise in the 
common case.

When you are forced to add {} for simple variables, the entire 
feature loses its point, even worse when you add expressions with 
function calls and what not.
1) "%s %s %s".format(a+1, b+1, c+1)
2) "${a+1} ${b+1} ${c+1}" (DIP1036)

Funnily enough, alias parameters can already handle runtime 
variables...



More information about the Digitalmars-d mailing list