I agree that in retrospect we should have defined multi-line literals that respect indentation. But that boat has sailed a long time ago. The question is whether the better usability is enough to warrant two different string literal syntaxes.
So let’s see what is the downside of the current approach. Here’s what we can do now:
println:
"""here are some
| lines of random
|text.
|""".stripMargin
Here’s the same with the proposed new syntax:
println:
'''
here are some
lines of random
text.
'''
The two extra elements are the “|” delimiters and the final .stripMargin call. The stripMargin is admittedly ugly. It would be better if there was a shorter version, like this:
println:
"""here are some
| lines of random
|text.
|""".sm
One could also roll this into the string interpolators. Say d for simple de-dent, then sd, fd, and so on. That would give:
println:
d"""here are some
| lines of random
|text.
|"""
Are these variants usable enough, or do we need a separate syntax for these new string literals? I tend to think there are more important things to improve but am ready to be convinced otherwise.