Small feedback from LJC talk

Cay Horstmann cay.horstmann at sjsu.edu
Sun Jun 3 16:44:05 UTC 2018


Le 29/05/2018 à 15:18, Stephen Colebourne a écrit :
> I spoke at the LJC to about 20 attendees on various project Amber
> features. Here are the slides and some small points of feedback:
> https://www.slideshare.net/scolebourne/amber-and-beyond-java-language-changes
> 
> Raw String Literals
> --------------------------
> I presented the puzzler to do with empty strings. 2 out of 20 guessed
> the right answer (multiple choice) but everyone (even those 2 people)
> groaned at the multi-line raw string hidden by apparent empty string
> literals. (see the presentation if you want to understand the exact
> code sample). The same happened at the last conference. No one has
> seen past the "empty strings". At least I've shown its a good puzzler
> for conferences...
> 

I thought about this, and there is a simple remedy (quite possibly 
discussed previously) to solve this and two other problems. I wrote up 
my thoughts at http://horstmann.com/unblog/2018-06-01.

Here is the remedy. Have two forms of raw strings.
1) Left and right delimiter: single backticks
2) Left delimiter: AT LEAST THREE backticks and a newline. Right 
delimiter: The same number of backticks.

Advantage #1: Stephen's `` puzzler isn't valid
Advantage #2: You can form raw strings that start with ` (using the 
second form)
Advantage #3: Less temptation to mess with "margin management"

    String myNameInABox = ```
+-----+
| Cay |
+-----+```; // Starts and ends with +

Note that the first character is the +, not a newline. If you want a 
trailing newline, add it.

    String myNameInMarkdown =
````
```
Cay
```
````; // Starts with ``` and ends in newline

I much prefer the raw multiline string not to be indented. Often, it 
will have long lines, and it's also good for it to stand out as non-Java 
code. It's just the first line that is an issue--which is solved by 
having the newline a part of the delimiter.

Cheers,

Cay

-- 

Cay S. Horstmann | http://horstmann.com | mailto:cay at horstmann.com


More information about the amber-dev mailing list