RFR: 7903727: Remove the reliance on String Templates feature [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon May 20 17:02:15 UTC 2024
On Mon, 20 May 2024 16:51:00 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
> > we could use a different way to format messages, more similar to MessageFormat where arguments have indices that can be used in the format message (so they can be repeated, reordered, etc.).
>
> `String.format` also supports referencing arguments by index, e.g. `String.format("%2$s %1$s", "A", "B")` would produce `"B A"`, and the same argument can be referenced multiple times as well. I suggest we use that for the longer text blocks with multiple embedded values.
Good point, I never used this escape hatch :-)
I wonder though if readability of that is good enough. The problem with message format of course is need to escape `{` which are quite common in code...
So perhaps we can use the trick suggested by @JornVernee in selected places and maybe tinker later (e.g. maybe come up with our own templating solution, if we really need that).
-------------
PR Comment: https://git.openjdk.org/jextract/pull/244#issuecomment-2120840188
More information about the jextract-dev
mailing list