Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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).


This is such a good idea I just added it to my current toy language:

https://github.com/TazeTSchnitzel/Firth/commit/7b9bf0b4c090e...

Thanks for the idea! :)


I'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.


Also, 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.


This 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.


> 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-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.


Easier to type too. No need to press the shift key.


Perl6, 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


Add 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: