D - Multi line strings
- Patrick Down (33/33) Jun 14 2002 Walter how would you feel about a multiline
- Martin M. Pedersen (25/28) Jun 14 2002 In shell scripts you have "here documents", and they are quite handy :-)
- Patrick Down (3/28) Jun 14 2002 Yes this would be an ideal solution.
Walter how would you feel about a multiline
string delimiter. For example I currently have
this string that I use as part of a unit test
for a parser. It would be a nice to write
it like this, where """ indicates a string that
spans over more that one line.
char[] test1 = """
variable=value
var = "Hello there"
truth=true
number=456
newdict=foo{
testv=false
aaa=Hello
}
thelist=[ 12 34 "beagle" ["its log" 12 ] hot { foo=bar } ]
""";
Instead it's written like this which is a little
harder to deal with.
char[] test1 =
"variable=value\n"
"var = \"Hello there\"\n"
"truth=true\n"
"number=456\n"
"newdict=foo{\n"
" testv=false\n"
" aaa=Hello\n"
"}\n"
"thelist=[ 12 34 \"beagle\" [\"its log\" 12 ] hot { foo=bar } ]\n"
"\n";
The only problem I see is that different platforms have
different end of line character sequences.
Jun 14 2002
Hi,Walter how would you feel about a multiline string delimiter.In shell scripts you have "here documents", and they are quite handy :-) They would be handy in D too.The only problem I see is that different platforms have different end of line character sequences.That could be solved by explicitly specifying how end-of-line characters should be represented. Something like this: char[] document = here("\n",EOF) variable=value var = "Hello there" truth=true number=456 newdict=foo{ testv=false aaa=Hello } thelist=[ 12 34 "beagle" ["its log" 12 ] hot { foo=bar } ] EOF "here" would then be a keyword recognized by the lexer, the first argument specifies the end-of-line representation, and the second argument is an identifier used to mark the end of the string. One thing a don't like about here documents as they work in shell scripts, is that they either breaks indention, or they introduce unwanted indention in the here document. Regards, Martin M. Pedersen
Jun 14 2002
"Martin M. Pedersen" <mmp www.moeller-pedersen.dk> wrote in news:aedahl$ctk$1 digitaldaemon.com:Hi,Yes this would be an ideal solution.Walter how would you feel about a multiline string delimiter.In shell scripts you have "here documents", and they are quite handy :-) They would be handy in D too.The only problem I see is that different platforms have different end of line character sequences.That could be solved by explicitly specifying how end-of-line characters should be represented. Something like this: char[] document = here("\n",EOF) variable=value var = "Hello there" truth=true number=456 newdict=foo{ testv=false aaa=Hello } thelist=[ 12 34 "beagle" ["its log" 12 ] hot { foo=bar } ] EOF
Jun 14 2002








Patrick Down <pat codemoon.com>