From interlink.sg7 at gmail.com Wed Aug 7 17:37:16 2019 From: interlink.sg7 at gmail.com (interlink.sg7 at gmail.com) Date: Wed, 7 Aug 2019 19:37:16 +0200 Subject: JEP 355 Text Blocks, final new-line CR Message-ID: <003801d54d46$c1f7a720$45e6f560$@gmail.com> Hello, This ist the first time I'm writing to the OpenJDK devs and I'm not sure if this is the correct place to do so, I apologise if it isn't. I recently saw the (http://cr.openjdk.java.net/~jlaskey/Strings/TextBlocksGuide_v8.html). First I'm really glad that you moved away from the String Literal proposal and especially that you're not planning to to use the backtick as marker anymore. The backtick is a dead-key on many keyboards and would be inconvenient to type. However I was quite bothered that newlines are added at the end of textblocks when the end-marker (""") is on a new line. Is there a good reason for this? I think developers would have some benefits if it wouldn't do that. In consequence the end-marker would need to on its own line, the same way as the start-marker needs to be followed by a line-terminator. - An automatic final newline is often not desirable. E.g. HTML or SQL or prose that we wish to include as a textblock. Some examples in the seem to be unnaturally constructed to fit the resulting textblocks. - The final newline it is even in the way. E.g. Valid Python code or when concatenating two textblocks. Without newlines at the end, concatenation would feel similar as we are used to it now. - It's harder and inconvenient to remove a newline after creating the textblock. The textblock will often be used as a static final constant field. There's is currently no easy way to do this with the JDK alone. It would require import to org.apache.commons.lang3.StringUtils::chomp. In contrast it would be easy to add a final newline if it was really required. Simply adding an empty line before the end-marker. - . The resulting String would always entail the textblock between the markers. If there's a final newline, it would be clearly visible as a newline in the block. - Singleline textblocks would be visually appealing. It would be and look consistent with multiline textblocks. You could express indents in singleline textblocks without having to use String::indent after creation. For examples: private static final String PARAGRAPH = """

"This is a paragraph!"

"""; Would result in: |

"This is a paragraph!"

Kind regards, Simon