This is not a compelling argument IMO.
There are two ways that one can think about the semantic value of “zig-like” multi-line string literals:
- Take everything after the
\\until the beginning of the next line. Take all such results until you reach a non-whitespace/comment token. Concatenate them, then remove the terminating line ending, if any. - Take everything after the
\\until just before the next line ending. Take all such results until you reach a non-whitespace/comment token. Join them with\nas a separator.
What you are describing is #1, but notice that #2 is:
- Slightly cognitively simpler (no special case for the last line)
- A better experience for Windows users (no need for every repo to have a .gitattributes with
*.zig text eol=lf) - How zig currently operates:
If you make this source file with CRLF line endings:
pub fn main() void {
std.debug.print("{q}", .{
\\asdf
\\
});
}
You’ll get as output:
"asdf\n"
But I also don’t think comparing “LF vs CRLF” and “spaces vs tabs” is particularly helpful. The former is mostly a matter of operating system defaults, while the latter is mostly a matter of personal preference. So even if we want to enforce a very strict style in zig, we should be lenient about things that a user doesn’t control (at least without doing a bunch of extra work).
Personally, I don’t use tabs, so I won’t care much if they’re disallowed, but I feel like making them a compile error is probably a bridge too far. Consider users trying out zig for the first time. How many users who are used to tabs will stop using the language before they understand how awesome it is, just because they’re used to using tabs and don’t want to change? Are the advantages of enforcing a no-tabs policy at the compiler level worth losing those users? I agree with a couple of the other posters here; the way to go is just having zig fmt change tabs to spaces, but not having the compiler complain if they’re present.