[OT] C# can do all the interpolated strings now

deadalnix deadalnix at gmail.com
Thu Dec 9 10:43:07 UTC 2021


On Wednesday, 8 December 2021 at 10:46:31 UTC, WebFreak001 wrote:
> https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated#compilation-of-interpolated-strings
>
>> Beginning with C# 10, when an interpolated string is used, the 
>> compiler checks if the interpolated string is assigned to a 
>> type that satisfies the interpolated string handler pattern
>
> Usage example: 
> https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/interpolated-string-handler
>
> What do you think of these extended interpolated string 
> expressions? I think these would fit well into D, and could 
> give some new motivation now that we have had our interpolated 
> strings DIPs rejected once and withdrawn once.

Disclaimer: I have not watched the what C# did before writing 
this.

So I read the proposal for string interpolation in D, which I 
understand to be this one: https://github.com/John-Colvin/YAIDIP

The immediate thing that stroke me is the shell example. The 
proposed exemple is simply terrible code as it allows for shell 
injection.

One of the motivating example is SQL prepared statements, but 
once again, replacing this by the proposed string interpolation 
means SQL injection.

In its current form, I'm not convinced the current proposal is 
something we want. If this reaches any kind of scale, this will 
inevitably end up as a forbidden language construct in a linter.


More information about the Digitalmars-d mailing list