3 ms·
This might seem strange, but if there's one thing from Common Lisp that should receive wider adoption in other languages, it's hyphenated names. They are so muc
by _pmf_ 12y ago
This might seem strange, but if there's one thing from Common Lisp that should receive wider adoption in other languages, it's hyphenated names. They are so much more readable than anything else (well, C with underscores comes close).
- rdtsc 12y agoEasier to type too. No need to press the shift key.
- jewel 12y agoThis would be an easy text-transformation that you could do in vim. Upon opening the file, translate all dashes without spaces "foo-bar" to add spaces "foo - bar". Then convert all underscores to dashes. "foo_bar" to "foo-bar". On save, invert the process. You'd have to actually run the language's parser in order to do the transformation to avoid changing strings, and even then it'd only work if the parser output kept track of the original line and character so that you could know where to make the change. This sort of text-transformation is something I've long wished my text editor did. At a previous job the standard was three-spaces of indent, regardless of the language.
- klibertp 12y ago> This sort of text-transformation is something I've long wished my text editor did. Emacs does this in some cases: specifically for camelCasedWords (http://www.masteringemacs.org/article/making-camelcase-readable-glasses-mode http://www.masteringemacs.org/article/making-camelcase-reada...) and for the word 'lambda' which can be displayed as a symbol. There are many other modes which "overlay" some text over how it looked originally.
- TazeTSchnitzel 12y agoThis is such a good idea I just added it to my current toy language: https://github.com/TazeTSchnitzel/Firth/commit/7b9bf0b4c090efa24944044741d541cb46423ecc https://github.com/TazeTSchnitzel/Firth/commit/7b9bf0b4c090e... Thanks for the idea! :)
- thomasfoster96 12y agoI've been playing around with creating a toy language which treats '-' as a name for a function. It means there always needs to be white space around a - (the syntax of the language isn't like LISP), but that increases readability at the cost of two extra key presses.
- kazinator 12y agoAlso, note that, in the same breath practically, you can support true negative integer constants: -1234 which are distinguished because there is no whitespace. You can distinguish the unary operator being applied to 1234 from a true -1234 constant.
- draegtun 12y agoPerl6, Clojure, Racket, Rebol, Red, Factor & Forth are some other languages that allow hyphenated names. And I agree with you that hyphens are more readable. They're also good for adding extra semantic meaning - https://news.ycombinator.com/item?id=3978992 https://news.ycombinator.com/item?id=3978992
- kazinator 12y agoAdd to that list, GNU Make. In gmake, you sometimes need things that look like paths to be variable names: VAR_$(PATH) := whatever where PATH could be path/to/foo-parser.o, say.