Are templated string embedded expressions "method parameters" or "lambdas"?

Jim Laskey james.laskey at oracle.com
Sat Oct 30 22:25:22 UTC 2021


Though I agree it's not a strong argument, but comment content is arbitrary. It's either /*  arbitrary characters */ or // arbitrary characters <eoln>. String content has to be contextual interpreted, i.e. have knowledge of valid escape sequences or translation of eoln.

String s = """
\{"abc\"}"}
""";

Also,  do we allow

String t = """
\{"\{\"abc\"}"}
""";
or

String t = """
\"""
\{"\{\"abc\"}"}
\"""
""";

It's not impossible to parse, just a little more complicated than just counting braces.

On Oct 30, 2021, at 6:13 PM, Guy Steele <guy.steele at oracle.com<mailto:guy.steele at oracle.com>> wrote:



On Oct 29, 2021, at 10:10 AM, Jim Laskey <james.laskey at oracle.com<mailto:james.laskey at oracle.com>> wrote:

For our early templated string prototypes, we restricted embedded expressions to just basic accessors and basic arithmetic. The intent was to keep things easy to read and to prevent side effects. Over time, we began thinking this restriction was unduly harsh. More precisely, we worried it that it would result in a complex, difficult-to-defend boundary. But we still would like users to not rely on side-effects.

Consequently, a new proposal for embedded expressions - we would allow any Java expression with the restriction that you can't use single quotes, double quotes or escape sequences. We opted to keep this restriction to allow tools (ex., syntax highlighters) to isolate embedded expressions within strings without requiring sophisticated parsing.

An interesting restriction. Would comments also be forbidden within such expressions (for the same reason)?

—Guy



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20211030/b37ac403/attachment.htm>


More information about the amber-spec-experts mailing list