While I get where you're coming from, I don't think that part is
anything new or scary. This is isomorphic to methods like:
static Foo EVAL(String script, Object... params) { ... }
The slightly more convenient syntax may seem attractive at first, but
ultimately, it's not really all that different from the EVAL method
above; the difference between
EVAL."Foo \{foo} Bar \{bar}"
and
EVAL("Foo {} Bar {}", foo, bar)
is not the difference between "macros" and "no macros".
I am sure we'll see interesting abuses, but that's not the point.
So, what is the point? The point is that string interpolation is one of
the most commonly requested features, and we'd make a lot of people
happy if we did it. While it's a harmless-seeming feature in theory,
we're unwilling to do the weak version of string interpolation that most
other languages have satisfied themselves with (we can justify this
unwillingness solely on the SQL injection risk, but there are other
reasons.) So if we want to make all those people happy, we have to do a
version that is smart enough to address the obvious security hazards.
This proposal seems to me about as close as we're going to get to making
the people happy while addressing the required constraints, without
doing something totally crazy.
On 9/16/2021 8:10 PM, Remi Forax wrote:
Brian explicitly ask me to not talk about invokedynamic so i will not
say that there is already an existing protocol between invokedynamic
and a user defined implementation, it's the bootstrap method,
Let's talk about the elephant in the room: macro.
Templated Strings as currently defined is indiscernible from a
hygienic String based macro system [1].
Using javac as an API (like jshell does), it seems trivial to come
with something like EVAL."\(a) + \(b)" being able to evaluate at
runtime any Java expressions.
I'm not sure if it's a good thing or a bad thing.
Rémi
[1] https://en.wikipedia.org/wiki/Hygienic_macro
------------------------------------------------------------------------
*From: *"Jim Laskey" <james.las...@oracle.com>
*To: *"amber-spec-experts" <amber-spec-experts@openjdk.java.net>
*Sent: *Jeudi 16 Septembre 2021 15:28:41
*Subject: *String Tapas Redux: Beyond mere string interpolation
Amber experts,
Now that JDK 17 has been plated and left the kitchen, we should
have a look-see at one of the new menu items Brian and I have had
on a slow boil for these last few months; Templated Strings.
Before you start shouting out, "Templated Strings? This isn't what
I ordered! The subject said string interpolation!!!", take the
time to follow this link
https://github.com/openjdk/amber-docs/tree/master/site/design-notes/templated-strings.md
<https://github.com/openjdk/amber-docs/tree/master/site/design-notes/templated-strings.md>.
After reading, we hope you'll see that the offering is much better
than interpolation meat and potatoes.
Cheers,
-- Jim