News for hackers. Stuff that matters.
Re:ASCII and Unicode quotation marks by tome on Wednesday September 13, 2017 @05:15PM (#15242769)
If ASCII had balanced quotes then they would be used by programming languages to delimit strings and we would be back to square one with regards to escaping them!
Re:ASCII and Unicode quotation marks by hk__2 on Wednesday September 13, 2017 @05:47PM (#15243027)
You don’t need escaping in «This is a string containing an «embedded» quoted string».
Re:ASCII and Unicode quotation marks by cassowary on Wednesday September 13, 2017 @11:15PM (#15244743)
«Hi. How do I open a quote?»

«Oh, you just use the « character.»

Parse error. Unexpected EOF.

Re:ASCII and Unicode quotation marks by hk__2 on Friday September 15, 2017 @12:50PM (#15258604)
That wouldn’t be a good idea but you could adapt your parser to support that case. You can write `/* /* */` in C, for instance.

To clarify: we’d still need escaping but in fewer cases.

Re:ASCII and Unicode quotation marks by tedunangst on Wednesday September 13, 2017 @06:05PM (#15243166)
Debatable whether that would actually work in practice.

    /* nested /* comments */ don't work */
Re:ASCII and Unicode quotation marks by int_19h on Wednesday September 13, 2017 @09:58PM (#15244453)
They don't work in C, but that's an arbitrary decision made by its designers. There are many languages that have balanced comments that can be nested. In OCaml, for example, this is legal:

    (* nested (* comments *) work *)
Re:ASCII and Unicode quotation marks by jraph on Thursday September 14, 2017 @04:59AM (#15246116)
This is possible in D using /+ comments +/.

https://wiki.dlang.org/Commenting_out_code#Nested_comments

This allows commenting out code containing comments, which can be useful when debugging or giving usage examples in the code.

Re:ASCII and Unicode quotation marks by drdeca on Wednesday September 13, 2017 @05:52PM (#15243065)
I think it would make the parsing a tiny bit more inconvenient though
Re:ASCII and Unicode quotation marks by Pxtl on Wednesday September 13, 2017 @09:39PM (#15244364)
Yup, suddenly your parser needs to keep a count of how many nested strings deep it is.
Re:ASCII and Unicode quotation marks by munificent on Thursday September 14, 2017 @12:02AM (#15244914)
It's not hard. Obviously the parser has to do that things that aren't a single token like parenthesized expressions.

Even for things where the nesting does happen during lexical analysis, it's pretty trivial to keep a count in your lexer. Lots of languages support nesting comment syntax or string interpolation, which both have equivalent difficulty.

Re:ASCII and Unicode quotation marks by userbinator on Wednesday September 13, 2017 @10:17PM (#15244537)
Don't forget that "parser" also includes human brains, which tend to not be that great at parsing nested things.

To use formal language theory, strings containing escape characters are regular, i.e. parseable with a finite-state machine. Allowing nesting means you need a stack to find the matching pair.

Re:ASCII and Unicode quotation marks by hk__2 on Friday September 15, 2017 @12:44PM (#15258554)
It’s trivial to do; parsers handle nested things quite easily.
Re:ASCII and Unicode quotation marks by jrochkind1 on Wednesday September 13, 2017 @09:52PM (#15244429)
ruby does that. computers are pretty fast now.
Re:ASCII and Unicode quotation marks by Someone on Wednesday September 13, 2017 @07:32PM (#15243727)
So, how would you encode this in a string:

  To end a string, use the » character.

?
Re:ASCII and Unicode quotation marks by hk__2 on Friday September 15, 2017 @12:51PM (#15258613)
You escape it. What I was saying was nested strings wouldn’t need escaping.