RFR - Implementation of JEP-430 String Templates (Preview) CSR

Remi Forax forax at univ-mlv.fr
Wed Oct 26 09:25:58 UTC 2022


Each time i re-read this JEP, i'm more and more sorry about its state. 
- we are breaking how Strings worked, now everything in between "..." is not a String anymore. 
As an example, given a String s, only one of the following lines compiles 
System.out.println("s = \{s}".toUpperCase()); 
System.out.println("s = {\s}".toUpperCase()); 
- conceptually we have something like 
instance -> template -> arguments 

but instead of grouping it like this 
Class.apply(template).invoke(instance, arguments) 

the JEP groups them like this 
instance.apply(new TemplatedString(template, arguments)) 

which is far less efficient because both the class and the template are constants while the instance and the arguments are not. 

Rémi 

> From: "Jim Laskey" <james.laskey at oracle.com>
> To: "core-libs-dev" <core-libs-dev at openjdk.java.net>
> Sent: Tuesday, October 25, 2022 6:41:05 PM
> Subject: RFR - Implementation of JEP-430 String Templates (Preview) CSR

> Request for a broader review of the String Template APIs for JEP 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.

> CSR: [ https://bugs.openjdk.org/browse/JDK-8286021 |
> https://bugs.openjdk.org/browse/JDK-8286021 ]
> JEP: [ https://openjdk.org/jeps/430 | https://openjdk.org/jeps/430 ]

> Thank you.

> — Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20221026/432bc147/attachment-0001.htm>


More information about the core-libs-dev mailing list