top | item 43751869

(no title)

thatnerdyguy | 10 months ago

C# has InterpolatedStringHandler which isn't quite the same thing, but (in my understanding), trying to address the same core issues.

discuss

order

WorldMaker|10 months ago

C# InterpolatedString is very close, with the twisty bit being that C# can rely on static typing for safety so the "f-string" and "t-string" variants use the same literal syntax and depend on what function they are passed to, whereas in both Python and Javascript they have different literal syntaxes. Python chose to use a different literal prefix to its literals ("f" versus "t") and Javascript chose to use a function-call syntax as prefix (`templateString` versus html`templateString` where html is a function in scope).

neonsunset|10 months ago

For the case like here it’s closer to FormattableString that’s what EF Core’s composable FromSql method works on top of. Both address custom interpolation but from different angles / for different scenarios.