4 ms·
By the way, I always wondered why not just take a lisp, put every single thing (even an operator) on a separate line and indent every level of parentheses with
by qwerty456127 4y ago
By the way, I always wondered why not just take a lisp, put every single thing (even an operator) on a separate line and indent every level of parentheses with a space or two (4 spaces is too much - deep nesting would go too much to the right). So there would be no need for the parentheses in most cases.
- abrax3141 4y agoWhat would this accomplish aside from spreading your code all over the screen, making it both hard to read and edit, and reducing your freedom of formatting for semantic sense?
- nlitened 4y agoThen programs will be too long. Too much scrolling, less information density on screen, more difficult to comprehend.
- Syzygies 4y agoThis is a divisive question, because of survivorship bias. Remember when the WWII Brits wanted to reinforce planes where they saw bullet holes coming back, till a statistician asked why no planes came back with holes in the other spots? People who use lisp like the parentheses. I don't, though they're no more objectionable than all the {}; languages. I just don't like unnecessary punctuation. I coded in scheme for years using a preprocessor that understood define-syntax opt syntax-rules | $ _ (x v) b ... let || x | if (null? x) v | car x b ... which is line for line equivalent to (define-syntax opt (syntax-rules () ((_ (x v) b ...) (let ((x (if (null? x) v (car x)))) b ...) ))) It's a matter of taste, but I'd rather read the former. The key ideas, other than using indentation to carry parenthesis level, are to use $ to hang double indents, and | to open a parenthesis that auto-closes. I gave this up learning Clojure so I could use other people's tools. Instead I prefer lighter parentheses, and I use this script to tailor fonts for coding lisp: https://gist.github.com/Syzygies/226253bc38743ef474ee67cbf584cb2b https://gist.github.com/Syzygies/226253bc38743ef474ee67cbf58... I have the most trouble with comment characters, in any language. In various languages I used a preprocessor that implemented a practical version of "comments are flush, code is indented" (hey, it cost me one level) and relied on syntax coloring to mute the comments. Again, I gave this up to use other people's tools.
- afranchuk 4y agoI think sweet-expressions[0] address this, though they haven't caught on much. [0]: https://dwheeler.com/readable/readable-s-expressions.html https://dwheeler.com/readable/readable-s-expressions.html
- martinflack 4y agoIf you learn Lisp, both the language and the tooling, you'll come to really like the parens. I suggest to everyone who uses Lisp, just set your editor's syntax highlighter to make the parentheses fade into the background color almost completely. They're still there, for correctness, structured editing, and ease of sharing with others; but they don't stand out.
- kazinator 4y agoA technical reason not to do that is that if you have the parentheses and the indentation then you have the structure encoded in two ways. This is useful; if the two differ, that indicates a problem. Another technical reason is that we work with text based version control tools, under which we use whitespace-insensitive diff as a hack to hide some differences that don't make a difference. That tool becomes unreliable over indentation-only languages; you can make a semantic change whose whitespace-insensitive diff is empty. Another technical reason not to go indentation-only is that you don't know whether a partially obscured block of code is complete or just a prefix: |defun foo(): | bar() | xyzzy() +---------- < window border am I looking at all of foo, or do I have to scroll down to see more? Here you know it's the whole thing: |(defun foo(): | (bar) | (xyzzy)) +---------- < window border
- gilch 4y agoSomething like Hebigo? https://github.com/gilch/hebigo#examples https://github.com/gilch/hebigo#examples