JEP 430: String Templates Mandatory TemplateProcessor

interlink.sg7 at gmail.com interlink.sg7 at gmail.com
Fri May 12 10:49:36 UTC 2023


Hello,

I tried out the early-access build of JDK 21 and saw that the
TemplateProcessor seems to be mandatory now for String Templates:

 

    var hello = "Hello \{name}"; ==> error: processor missing from template
expression

 

The JEP says: "Thus if we forget to use a template processor such as STR,
RAW, or FMT then a compile-time error is reported".

 

I know you dread this kind of discussion, but if that is the case, would we
now be able to reconsider ${.}?

The original reason behind \{.} was to avoid conflicts with legacy code.

Using ${.} would require a tag on string templates (either a prefix or a
delimiter other than "). See Alternatives section in the JEP.

However if the TemplateProcessor . TemplateArgument is mandatory it kinda
acts as a tag anyway?

Backwards compatibility is still ensured as far as I can tell.

 

Note that there is a very strong backlash against the backslash (play on
words intended) in the Java community.

 

Kind regards,

 

Simon

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20230512/90351f72/attachment.htm>


More information about the amber-dev mailing list