3 ms·
Most (newer) programming languages have a concept of multi-line string literals.
by 0xdeadb00f 5y ago
Most (newer) programming languages have a concept of multi-line string literals.
- conradludgate 5y agoMost newer languages only have 1 variation, not infinite. Go only has backtick, python only has triple quotes. Rust has #", ##", ###", ##...#"
- Rendello 5y agoMy favourite variation is from Zig: const hello_world_in_c = \\#include <stdio.h> \\ \\int main(int argc, char **argv) { \\ printf("hello world\n"); \\ return 0; \\} ; It neatly sidesteps the whole "cat-and-mouse" issue. Pair this with the fact that it only has the C++ style // comments, it means that every line can be tokenized independently. Not that that particularly matters for programmers, but I know Vim sometimes gets confused about where Python's strings end and it turns the syntax highlighting to garbage.
- afiori 5y agoit also fixes the indentation problem