2 ms·
hyphen-case is worth the grammar concessions (like making whitespace between binary operators mandatory).
by keybored 2y ago
hyphen-case is worth the grammar concessions (like making whitespace between binary operators mandatory).
- dailykoder 2y agosPoNgEbOb-CaSe combined with hyphens is the only viable solution
- stock_toaster 2y agokebab-case and SCREAMING-KEBAB-CASE are often found in urls too
- IshKebab 2y agoYeah no thanks. Soo `a-b` and `a - b` are both potentially valid and different? Also allowing hyphens generally leads to issues when interoperating with other languages that don't support hyphens. Probably the best example of this is CSS which does allow hyphens, and Javascript which doesn't. `background-color` in CSS gets translated to `backgroundColor` in JS. It's an annoying paper cut that trips up beginners and makes code less greppable. I generally avoid hyphens wherever possible for that reason.
- ReleaseCandidat 2y ago> Soo `a-b` and `a - b` are both potentially valid and different? You shouldn't be able to start a name with a hyphen, so `a -b` and `a - b` can be both valid. But I mostly just came to acknowledge your fitting username ;)
- keybored 2y ago> Yeah no thanks. Soo `a-b` and `a - b` are both potentially valid and different? Like what the sibling comment said: `-b` should be illegal. And I don’t think this would be a big deal in practice for experienced users (used to these rules). For beginners you could build in an error check: give a dedicated error message if you write `a-b` but you happen to have both variables `a` and `b`. Then the compiler can tell that you probably meant `a - b`. > Also allowing hyphens generally leads to issues when interoperating with other languages that don't support hyphens. Make underscore illegal in the language. It’s not like you need them anymore. In turn you have a bidirectional translator.
- IshKebab 2y ago> `-b` should be illegal Sure... but I didn't use `-b`. Maybe I've misunderstood. > give a dedicated error message if you write `a-b` but you happen to have both variables `a` and `b` I guess, though the idea of having mutually exclusive sets of identifiers sounds like a nightmare. You can have `a` and `a-b`, or `a` and `b`, but not `a`, `b` and `a-b`... Maybe it wouldn't come up much in practice but it's still a pretty big WTF. > In turn you have a bidirectional translator. But the problem is that you have this translation in the first place. It makes the identifier ungreppable. Ideally any place you have an identifier it looks exactly the same through your whole codebase and if you have to translate it then that is no longer true. For example if you want to update all background colours in your project you might search for `background-color`... but miss `backgroundColor`.