Some observations on JEP draft of Templated Strings and Policies
Alejandro
alxegod at gmail.com
Sat Oct 16 17:08:27 UTC 2021
Hello,
For some context, I am a simple fan of Java, as I don't even use it on
my daily job, and have just recently started being an observer of it's
development.
Now, while browsing Reddit's r/java, I saw that JDK-8273943, Templated
Strings and Template Policies (Preview), had been updated.
I previously knew about the feature from, possibly, some posts in
either GitHub or inside.java, but didn't know as many details until I
read the JEP draft.
Overall, I like the additions quite a lot and want to congratulate
everyone's effort, but I had one observation, in particular with the
usage of java.util.List.
Let me quote the observations I posted on the Reddit thread:
> I don't like the idea of TemplatedString having a dependency on java.util.List, as it means that the latter would now be hard-coded into the language.
> A more sensible solution would be any java.lang.Iterable, which is already hard-coded into the language due to it's usage in for-each loops.
> This one, as oposed to java.util.List is a very simple and concise interface.
>
> From an implementor's point of view, they could continue using List::of.
> From a consumer's point of view, they could still make use of for-each loops, or construct a List easily, e.g. ts.values().forEach(myList::add).
I am pretty sure that you've considered or discussed this topic
before, but nonetheless I wanted to bring this into the mailing list.
My reasoning is so that I can be directed to some past discussion on
this, or to bring up the discussion if it hadn't popped up before.
As for current reasoning, I think this is to possibly have "mutable"
TemplatedStrings, such as replacing one element of values(), but this
is just an idea and doesn't align with the current example in the JEP.
Best Regards,
Alejandro
More information about the jdk-dev
mailing list