3 ms·
What other character would you suggest? At least multi line strings arent super common (nor essential) so extra difficulty isn't a major problem.
by benjoffe 15y ago
What other character would you suggest? At least multi line strings arent super common (nor essential) so extra difficulty isn't a major problem.
- masklinn 15y ago> What other character would you suggest? Fixing the language so newlines in strings are legal, Python-style triple quoting or some sort of string modifier prefix (similar to Python's rawstring modifier)
- program 15y agoI don't think that there is the need for a new character. The problem here is that JS has automatic semicolon insertion. This: var a = "abc def"; generate a "unterminated string literal" syntax error cause a semicolon is inserted after abc. Why not using C/C++/ObjC syntax? var a = "a very " "very long string";
- dbattaglia 15y agoThe only thing about the C syntax version is you still end up with a bunch of double quotes all over the place. The #1 reason I have for using multi-line strings currently is when writing full-out SQL or Javascript code inside C#; using C#'s @-prefixed strings make the whole thing a lot prettier to look at IMO. For me personally I'll probably never have to write multi-line JS strings more than once a year so I don't really care about the feature, but I do agree with their way of implementing them.