StringTemplate evolution

Brian Goetz brian.goetz at oracle.com
Tue Mar 19 20:09:04 UTC 2024


All fair comments, but as a gentle reminder: amber-dev is not the 
parallel-but-public design list to amber-spec-experts.

On 3/19/2024 3:56 PM, P Holder wrote:
> Now that it appears that StringTemplates are evolving to a special 
> introducer token, I hope it's also being recognized that they can then 
> also change to support a syntax that is more friendly and common with 
> other languages.  In particular, there would appear to be no need any 
> more to require the backslash to introduce the values.  The backslash 
> can now be reversed and offered to escape the open brace when it's 
> desired as a literal.
>
> To get the result: The value of foo is 42.
> Go from:
>   STR."The value of \{name} is \{value}.";
> to
>   $"The value of {name} is {value}.";
>
> and to get the result: The value of {foo} is {42}.
> Go from:
>   STR."The value of {\{name}} is {\{value}}";
> to:
>   $"The value of \{{name}} is \{{value}}";
>
> I'd also propose that you could use a keyword token instead of the $ 
> without causing too much grief.  This would have the benefit of 
> looking like a name, and allowing for future evolution in a direction 
> where you might want something additional and don't want to find an 
> additional punctuation character.
>
> So, where ST stands for StringTemplate a string template could look like:
>   ST."The value of {name} is {value}.";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/amber-dev/attachments/20240319/c2f01f85/attachment.htm>


More information about the amber-dev mailing list