RFR of JDK-8285932 Implementation of JEP-430 String Templates (Preview)

Alex Buckley alex.buckley at oracle.com
Wed Nov 16 23:59:15 UTC 2022


On 11/16/2022 3:41 PM, John Rose wrote:
> And yet, in the example given above, the list of fragments |List.of(" + 
> ", " = ")| is one element /smaller/ than the list of values |List.of(10, 
> 20, 30)|. The example is wrong. It’s worth a note in the doc that if an 
> interpolated expression begins and/or ends the template, there will be a 
> zero length fragment at the beginning or end of the fragments list.

Jim already caught and fixed the list examples in the latest javadoc, 
which says:

---
fragments will be equivalent to List.of("", " + ", " = ", "") and values 
will be the equivalent of List.of(10, 20, 30).
---

I agree that the javadoc should flag the existence of zero-length 
fragments; my later mail offered text for `fragments()` and `values()` 
which did so; that offering should be treated as merely the first draft 
of how to explain the reification of a source-code template.

Alex


More information about the compiler-dev mailing list