String template always requiring a processor
Jim Laskey
james.laskey at oracle.com
Thu Oct 27 19:19:37 UTC 2022
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.
Cheers,
— Jim
More information about the amber-spec-experts
mailing list