""" can't contain """ . Heredoc solves this issue by allowing user defined string delimiter.
Here's a heredoc string literal in D. Some other languages have that too (eg C++11, ruby etc); see https://dlang.org/spec/lex.html note, user can use anything, not just EOS; that's what makes them universally applicable.
auto s = q"EOS
This is a multi-line
heredoc string
EOS"
in Nim, this could look like:
let s= h"EOS we can have anything including """ inside it EOS"
In nim, it would be nice if that limitation were lifted; I'd suggest the following instead:
let s= h"EOS we can have anything including """ inside it
EOS"
let s= h"EOS(we can have anything including """ inside it)EOS"
which is allows to fit in 1 line, and doesnt' have limitation of string ending in newline
this is one thing where C++ designed it better than D IMO (see also https://stackoverflow.com/questions/19075999/what-is-the-rationale-for-parenthesis-in-c11s-raw-string-literals-r)
let s=h"!(put anything here except user defined delimiter!)" let s="""put anything here except triple quote"""
in short: heredoc is occasionally quite useful, eg if we need to write nim source code inside a string, where the source code itself contains triple quotes.
Python is one of the fastest growing languages and doesn't have a heredoc syntax.
heredoc is occasionally quite useful, eg if we need to write nim source code inside a string, where the source code itself contains triple quotes.
well, we have staticRead for that.