Updated spec for String Templates (JEP 430) now available
Brian Goetz
brian.goetz at oracle.com
Wed Nov 16 16:21:56 UTC 2022
The spec seems fuzzy on how we perform the equivalent of indentation
adjustment from text blocks. Suppose I have
String s = STR."""
Hello \{name}, it is \{time}
""";
This should result in the string "Hello Bob, it is 3:00". My
understanding of how it should work is something like:
- replace all the embedded expressions with a placeholder character;
- evaluate the resulting text block;
- split the text block at the placeholder to produce the fragment
literals.
But the spec says only:
> A template resembles a string literal or a text block but consists of
> the strict alternate interleaving of two or more string literals or
> text blocks, known as fragment literals, with one or more embedded
> expressions. An embedded expression can be either empty or an expression.
What is being interleaved is neither string literal nor text block, so
the use of "string literal" and "text block" seems off here, and I don't
see how the TextBlockTemplateFragment is processed for escapes and
whitespace the way we would with a TextBlock. So it seems a little work
is needed here?
More information about the amber-spec-observers
mailing list