5 ms·
A Short Quiz About Language Design
- informatimago 14y agoPostscript uses parentheses: (Good bye (cruel) world!) show showpage prints "Good bye (cruel) world!". Common Lisp uses | to quote symbol names: (print '|Hello World!|) prints: "Hello World!" But in all cases, (whatever the advantages of using rare, or balanced characters to quote strings), eventually you will need to insert one of those characters in a string, so you will need an escape mechanism anyways. It is not hard to understand. On the contrary, as soon as you need to quote text, you can instructively introduce this escape mechanism to quote the quoting character. "Hello ""small"" world!" "Hello \"small\" world!" |A string with a \| in it.| (There are two things: 1\) the one, and 2\) the second.) etc.
- Turing_Machine 14y agoWell, yeah, he mentions that. The point is that you typically need to use " and ' in text strings incredibly more often than you need to use | in them. It would be interesting to run some stats on github to determine how many person-years would be saved by not having \' and \" all over the place (not to mention the improved readability).
- Dewie 14y agoWhen I had a some class with Prolog, we copied some code from the lecture notes. The problem was that it wouldn't run, even though we had looked over it dozens of times and it was syntactically correct. Turns out that there was a string that was enclosed in quotes, but a different kind of quotation mark than what Prolog was using for strings. So the string was not syntax highlighted, and we noticed that if we deleted the quotes and typed in the quotes manually with the keyboard, those quotes had a font that was a little bit different. I think the problem was that he had written it on a Mac, and we were using Windows/Linux.
- pavel_lishin 14y agoIsn't it more likely that something like Microsoft word replaced plain ol' quotes with their "smart quotes"?
- Dewie 14y agoWe were using a text editor (notepad++ if it was Windows), and it would be pretty invading for a very basic text editor to change text like that (copy pasted at that). But honestly I don't know what these "smart quotes" are so it might as well be it. The only time that text encoding causes trouble is when I get something from someone who has written it on a Mac, whether it is the obscure quotation marks or a lot of gunk when copy pasting from PDFs.
- blktiger 14y agoWhat about using more that one double-quote characters(""some string"")? I can't think of any reason that you would do that in a particular string. Of course, you still need some way to escape it just in case, and there are always going to be special characters that you need to escape (like end of line characters), but you could probably get away with that for the majority of cases.