String template always requiring a processor

Remi Forax forax at univ-mlv.fr
Thu Oct 27 21:10:10 UTC 2022


----- Original Message -----
> From: "Guy Steele" <guy.steele at oracle.com>
> To: "Jim Laskey" <james.laskey at oracle.com>
> Cc: "amber-spec-experts" <amber-spec-experts at openjdk.java.net>
> Sent: Thursday, October 27, 2022 9:35:49 PM
> Subject: Re: String template always requiring a processor

> I agree that, because one can always use the RAW processor (which simply passes
> back the string template itself), always requiring a processor syntactically
> seems like a good way to go.
> 
> —Guy

yes,
I believe RAW can be written

  private static final TemplateProcessor RAW = template -> template;


> 
>> On Oct 27, 2022, at 3:19 PM, Jim Laskey <james.laskey at oracle.com> wrote:
>> 
>> We’ve been having a rethink after recent concerns expressed by several experts
>> over the current string template design leading beginners down the path only to
>> stubble over "string templates are not strings”. Our original view was that
>> users would soon learn to insert the STR, but after consideration, having the
>> surprise hit them at runtime is not a compelling selling point.
>> 
>> Consequently, we are changing things up to follow Tagir’s suggestion of always
>> requiring a processor; i.e., no naked StringTemplates. As a result, IDEs can
>> flag the problem when editing or have inspection insert the STR automatically.
>> For most users, STR would have been used anyway. So, this change really only
>> affects those requiring the unprocessed string template (me and one or two
>> other people). In those cases, users can use the RAW processor.
>> 
>> Making it easier for IDEs to detect and correct will help mute the grumbling
>> about naked StringTemplates not being string interpolation. As stated in the
>> JEP, making Java safe and secure is the goal. This is the way.

Hi Jim, thanks for listening,
regards.

>> 
>> Cheers,
>> 
>> — Jim

Rémi


More information about the amber-spec-observers mailing list