On Sep 19, 2013, at 1:56 PM, Oren Ben-Kiki <o...@ben-kiki.org> wrote:
> Just to make sure - how does the C++ syntax behave in the presence of line > breaks? Specifically, what does it do with leading (and trailing) white space > of each line? My guess is that they would be included in the string, is that > correct? It includes every single character that occurs in the source between the delimiters. So cout << R"(this is a string"); will print "this is", newline, horizontal tab, "a string". > At any rate, having some sort of here documents would be very nice. The C++ > syntax is reasonable, though I really don't have a strong preference here. It > might be more Rust-ish to use a macro notation instead: > str!(delimiter"....."delimiter), or something like that. Not possible. This syntax needs to be part of the lexer, and macros/syntax extensions operate on token trees, not on raw source characters. -Kevin > BTW, I found myself creating (in several languages) an "unindent" string > function that would (1) if the string starts with a line break, remove it; > (2) remove the leading white space of the 1st line from all the lines. > Applying this to "here documents" allows indenting them together with the > code that includes them. In Rust, the downside of this approach is that the > result isn't &'static any more... Not that this warrants making such complex > functionality a built-in of the syntax, of course. > > Oren. _______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev