7 ms·
Instead of escaping, we could also just prefix all our strings with their length. (Editor support appreciated.)
by eru 11y ago
Instead of escaping, we could also just prefix all our strings with their length. (Editor support appreciated.)
- thaumasiotes 11y agoNo, that fails to address nearly all the use cases of escaping. Escaping is the difference between printf("\n") and printf("n"), or between printf("d") and printf("%d"), or between (dog|cat)* (any number of repetitions of "dog" and "cat") and \(dog|cat\)* (a left paren, exactly one instance of "dog" or "cat", and any number of right parens). Those aren't differences of length. The only scenario marked length helps with is situations like "I need to use \"scare quotes\"".
- thaumasiotes 11y agoActually, I feel compelled to note that as written, \(dog|cat\)* doesn't do what I said; it matches stuff like this: (dog cat)))) cat What I said embarrassingly requires another set of non-escaped parens: \((dog|cat)\)* :(
- eru 11y agoGood point!