2 ms·
Eh, I reckon they’re fine. In shell scripts especially (and sometimes elsewhere), if I want an ANSI escape code, I’ll type the actual bytes I want, because it’
by chrismorgan 6y ago
Eh, I reckon they’re fine.
In shell scripts especially (and sometimes elsewhere), if I want an ANSI escape code, I’ll type the actual bytes I want, because it’s more reliable and easier to type <C-V><Esc> and see ^[ in Vim than it is to worry about whether I’m using \u001b, \u{1b}, \x1b, \033 or something else, and whether I have '', "", $'', $"", printf, echo -e, &c. &c. Speaking generally, if you use the actual control characters, the code will either fail to run (parse or compile error) or work, whereas encoding your control codes with escape sequences is more hit and miss. I’ve seen quite a few others using control characters in this way too.
Truth to tell, I’m quite liberal in using all of Unicode in my source code. About the only places I wouldn’t use the actual characters are when (a) the environment requires me to escape the thing; (b) the numeric values of the characters are more meaningful than the characaters themselves; and (c) when dealing with combining characters and modifiers, because otherwise they’ll do things like combine with the opening ' from the string/character literal.
- kazinator 6y agoI mean, in non-strawman examples of programming languages. The code will work, but how will it edit outside of your personal environment? Or print? If you quote it in a PDF paper, will it be copy-pastable? Basically I would worry about all that sort of stuff. If I have echo '^L' to clear the screen, and that program is sent to a line printer, will I get: echo ' [ paper ejected ] ' If you so much as "cat" your code to a terminal, all the codes get interpreted.
- morelisp 6y agoIn Emacs Lisp it's common to to include real ^L specifically to trigger page breaks from when printing code was more common (and it has page-aware navigation commands accordingly).