Discussion: string interpolation with char span #3375
Replies: 3 comments
-
Don't forget that string interpolation lowers to If you have a rule that |
Beta Was this translation helpful? Give feedback.
-
That's ToString. The point is to not create a string just for concat. Note stirng.Concat directly accepts spans. I suppose no format specifier would be allowed for such string much like const string interpolations. |
Beta Was this translation helpful? Give feedback.
-
Again, string interpolation is not sugar for concatenation. It's sugar for At face value this is obviously not possible. Hence my suggestion: the only way I could think through this is to define string interpolation as converting a Then you apply the optimization where, if the string interpolation can be lowered to concatenation, and other conditions are met, you elide the step of turning the span into a string, and you use the That also gets around your problem of what to do you've got more than 4 things to concat: you fall back to turning each span into a string, and you lose the optimization. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The runtime already provides
Concat
span overloads up to four arguments,$"{span[..4]}***{span[^4..]}"
For language support we probably need some other mechanism to support >4 interpolations.
Beta Was this translation helpful? Give feedback.
All reactions