Third draft spec for String Templates (JEP 430) now available

Alex Buckley alex.buckley at oracle.com
Thu Feb 9 18:19:23 UTC 2023


On 2/9/2023 7:28 AM, Gavin Bierman wrote:
> https://cr.openjdk.java.net/~gbierman/jep430/latest 

In 2.1, if we're going with the term "ambiguous", we should have some 
rationale for why the well known term "context-sensitive" isn't good enough.

I don't want to lose the term "context-free" entirely. Perhaps a note in 
2.2: "In early versions of the Java programming language, the lexical 
grammar was not ambiguous. Rather, it was _context-free_, meaning that ...".

In 2.3, it is incongruous that there is no statement about whether the 
syntactic grammar is ambiguous.

In 3.13, the content of a fragment is defined statefully/positionally, 
e.g., StringTemplateBegin: "... ends immediately before the sequence \{ 
that prefixes ***the first*** embedded expression"  e.g., 
StringTemplateEnd: "... begins immediately after the character } that 
postfixes ***the final*** embedded expression"  I don't think this 
statefulness is used to resolve ambiguities. If you defined "content" 
purely as the sequence of characters in the StringFragment of a 
StringTemplateBegin/Mid/End, do you lose anything?


Regarding the note at the end of 3.13:

The 4 and the 2 are separate input characters, they should have a space 
between them.

Please say "input character" throughout, not "character".

"The next twelve characters ~would be~ +are+ reduced to the tokens ..."

I was tripped up by `the following two input characters (i.e. the 
sequence } } ")` -- the word "two" is followed by an example of three 
characters -- contrast this with the later clause which puts the word 
"two" next to an example with two characters: `two input characters (the 
sequence } ")`   Let's be super-clear:

   The next input character, }, is ambiguous. It could be reduced to a
   Separator, or it could be reduced along with the following } and "
   input characters to a StringTemplateEnd.
   ...
   The remaining } and " input characters will then be reduced to a 
StringTemplateEnd.

The phrase "... provide the context of matching the ArrayInitializer" is 
used. Given the earlier bullet -- "... was not in the context of being 
recognized as a terminal ..." -- I was looking out for the word 
"recognizing" rather than "matching".

Alex


More information about the amber-spec-observers mailing list