Update on String Templates (JEP 459)

John Rose john.r.rose at oracle.com
Thu Mar 14 20:21:03 UTC 2024


On 14 Mar 2024, at 9:24, Clement Cherlin wrote:

>> Adding an empty interpolated value to signal a template is not a
> viable solution, because "\{}abc" is not equivalent to ST.of("abc").
> Running the current preview,
>
> RAW."\{}abc" produces StringTemplate{ fragments = [ "", "abc" ],
> values = [null] } which interpolates to "nullabc".

Surely that is a bug in the preview.  In making that suggestion I assumed that omitting the expression altogether was illegal in the current syntax.  Having empty brackets be illegal (instead of an obscure way to say “\{null}”), they would have been a way to force a string to be a template, as a compatible extension.   But it’s not my favorite suggestion; just something I put out there FWIW.


More information about the amber-spec-observers mailing list