News for hackers. Stuff that matters.
Re:Java String Interpolation final in Java 23 by masklinn on Saturday January 13, 2024 @09:21AM (#38980135)
> Sadly, true. Why is the template processor named `STR`, why not `f"String"`, like Python?

It looks like the prefix is pluggable so you can use different template processors, STR is just the default:

> STR is a template processor defined in the Java Platform. It performs string interpolation by replacing each embedded expression in the template with the (stringified) value of that expression.

> FMT is another template processor defined in the Java Platform. FMT is like STR in that it performs interpolation, but it also interprets format specifiers which appear to the left of embedded expressions.

> Developers can easily create template processors for use in template expressions.

This is similar to Javascript's `tagged templates`: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe.... Python's f-strings are very much lacking that.

Although I do agree that the syntax, both of the prefix and the interpolation symbol, is awful.

There are no comments on this comment yet.