3 ms·
I really dislike that many languages still allow you to do strings with single or double quotes. Why not just choose one and stick with it? It’s another pedanti
by ed25519FUUU 6y ago
I really dislike that many languages still allow you to do strings with single or double quotes. Why not just choose one and stick with it? It’s another pedantic thing that allow people argue about the “best way”
- runxel 6y agoFun thing: It might even help. I actually like this possibility since it gives you more meaning: E.g. I would always tag localized strings by encapsulating them differently. It's great!
- Ao7bei3s 6y agoBecause it lets you use single quotes ("isn't") or double quotes ('error: "%s"') without escaping ('isn\'t', "error: \"%s\""). A rare case where readability and consistency may not be the same. (Let's not argue about this, it's subjective. I'm aware of the obvious counter- and counter-counter-arguments, such as syntax hilighting and greppability.)
- ed25519FUUU 6y agoThe problem is that a single quote will often times appear in strings as well, and sometimes (like in the case of bash) can't even be escaped. So you end up requiring double quotes either way. Why not just settle permanently on double quotes? This is what Go and other languages did and I think it's a good idea.
- dragonwriter 6y ago> The problem is that a single quote will often times appear in strings as well, but they can't be escaped While having choice of quotes reduces the need for escaping, most languages that provide it also still support escaping. E.g., Ruby has double-quoted strings with escaping, single-quotes without, %Q(...) with, %q(...) without, and two different heredoc forms, with and without escaping (the forms that allow escaping also support interpolation).
- VWWHFSfQ 6y ago> This is what Go and other languages did and I think it's a good idea. Well Lua is about 30 years old and Go is, what, 10 years old? I would expect a language that is barely a decade old to improve on past ideas and mistakes.
- m4r35n357 6y ago\
- pansa2 6y agoWhat do you think about using the two different kinds of quote character for two different kinds of string literal? For example, double-quotes for literals that interpret escape sequences and do variable interpolation, and single-quotes for “raw” string literals?
- m4r35n357 6y agoLike the shell, nice!