New candidate JEP: 430: String Templates (Preview)

Remi Forax forax at univ-mlv.fr
Tue Sep 20 19:47:49 UTC 2022


----- Original Message -----
> From: "mark reinhold" <mark.reinhold at oracle.com>
> Cc: "amber-dev" <amber-dev at openjdk.org>, "jdk-dev" <jdk-dev at openjdk.org>
> Sent: Tuesday, September 20, 2022 8:10:20 PM
> Subject: New candidate JEP: 430: String Templates (Preview)

> https://openjdk.org/jeps/430
> 
>  Summary: Enhance the Java programming language with string
>  templates, which are similar to string literals but contain embedded
>  expressions. A string template is interpreted at run time by replacing
>  each expression with the result of evaluating that expression, possibly
>  after further validation and transformation. This is a preview language
>  feature and API.

Hi all.
My main concern is that the TemplatedString object erase the types, but apart trivial template processors, those types is either required or can be used in order to be more efficient.

By example, for a JSON template processor, if it can know that a template value is of type String, then it knows that it has to escape it but if its an int, this is not necessary.
With the current proposal, because the type is lost, each value has to be dynamically checked against all the possible classes, something that is not efficient.

Otherwise the spec is not clear how STR or FMT are introduced in the scope, it is magical ? does a static import is used ?

> 
> - Mark

Rémi


More information about the amber-dev mailing list