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

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Thu Dec 9 14:40:50 UTC 2021


On Thursday, 9 December 2021 at 14:25:10 UTC, Steven 
Schveighoffer wrote:
> What is that sql function doing? It's not just concatenating 
> strings, and it's also not anything I would ever want to use, 
> in original or interpolation form. It appears to suggest it's 
> going to happily do sql injection as well.

Well, the DIP does not propose string building, it is basically 
string-splitting with a bit of mixin… (kinda)

Anyway, you could define constants for SELECT, FROM and WHERE and 
get even better syntax:

```sql(SELECT, r[0], r[3], FROM, t[3], WHERE, c[6])```

Then let sql escape-wrap the parameters.

> For this fictitious example, maybe. But I already see huge 
> potential in my real actual libraries that I've written.

Ok, but maybe you could write even better libraries if D added 
custom literals instead? :-)

> You don't have to use it if you don't want to.

True, I don't use string interpolation in JavaScript much either. 
I use it everywhere in Python. The details matters a lot for it 
to increase readability.

I just wish D would focus more on providing generic solutions 
than N narrow special cases. I think these special cases are 
pushed in because people in the forums are too impatient to wait 
for the emergence of a generic solution. Understandable, but not 
good for the compiler/language over time.



More information about the Digitalmars-d mailing list