Hacker News new | ask | show | jobs
by PH95VuimJjqBqy 846 days ago
at no point in my life have I ever considered escape codes to be problematic.

ugly, yes. problematic? no.

3 comments

Not problematic. Just a little cumbersome. (And ugly, agreed.)

You can't always just copy and paste some text into code, without adding escape encodings.

Now write code that generates C code with strings, that generates C code with strings, and ... (ahem!)

It's not a big deal, but it isn't zero friction either. Relevant here because it might be the most prevalent example of what happens when even two simple grammars collide.

until you need to get your string through several levels of escape. how many backslashes to add? depends on how deep your pipe is and how each of those layers is defined
The only alternative is extracting them to other files or designing specialized string formats.
There is one obvious "specialized string format" that solves 99% of all escaping issues: use «balanced quotes». The real problem isn't escaping, it is that the same character is used both to open and close strings.
Or old Fortran style Hollerith constants. They consist of the string length, a "H" and the string itself. Like 13HHello, world!
Qwerty has ` and ', but for some reason we've decided that '' isn't " and " is the one true quotation symbol.
Won't you still have to escape the closing bracket if it occurs inside the string?
Only if you want to refer to it literally as a closing quote rather than having it act as a closing quote. That case is extremely rare.
Its definitely rarer than double or single quotes occurring in string. But I was wondering about the parent comment's concern of passing a string through multiple levels of escaping.

> until you need to get your string through several levels of escape. how many backslashes to add? depends on how deep your pipe is and how each of those layers is defined

I also once had to pick up around the house and it was oh so terrible.
> problematic?

Unless it's a regex....