String interpolation

The placeholder may be a variable name, or in some languages an arbitrary expression, in either case evaluated in the current context.

Some languages do not offer string interpolation, instead using concatenation, simple formatting functions, or template libraries.

String interpolation is common in many programming languages which make heavy use of string representations of data, such as Apache Groovy, Julia, Kotlin, Perl, PHP, Python, Ruby, Scala, Swift, Tcl and most Unix shells.

[10] JavaScript, as of the ECMAScript 2015 (ES6) standard, supports string interpolation using backticks ``.

Formatted string literals inspired by Python F-string are provided via the strformat module, the strformat macro verifies that the format string is well-formed and well-typed, and then are expanded into Nim source code at compile-time.

[12][13][14] Such a literal begins with an f or F before the opening quote, and uses braces for placeholders: The output will be: The output will be: Rust does not have general string interpolation, but provides similar functionality via macros, referred to as "Captured identifiers in format strings", introduced in version 1.58.0, released 2022-01-13.

These macros are converted into Rust source code at compile-time, whereby each argument interacts with a formatter.

The f interpolator is a compiler macro that rewrites a format string with embedded expressions as an invocation of String.format.

[16] Each item inserted into the string literal is wrapped in a pair of parentheses, prefixed by a backslash.