为什么通常在基于Lisp的语言中在一行上放置许多右括号? [英] Why is it customary to put many closing parentheses on one line in Lisp-based languages?
问题描述
通常代码如下所示:
(one-thing
(another-thing arg1 (f arg5 r))
(another-thing arg1 (f arg5 r)))
这样吗?:
(one-thing
(another-thing arg1 (f arg5 r))
(another-thing arg1 (f arg5 r))
)
更容易地添加和去除另一事物线(不去除和重新添加尾随括号)。还可以对单独的右括号(例如; end of the loop)进行一些注释。
It allows adding and removing "another-thing" lines more easily (without removing and re-adding trailing closing parenthesis). Also you can put a some comment on that lone closing parenthesis (such as "; end of the loop").
当我混合代码使用
推荐答案
这里有两个要点:
-
约定本身很重要。
Conventions are important in themselves. Sticking to wrapped parens means your code is more readable by other lisp programmers, and if you adopt this style you will also develop practice at reading theirs
如果你采用这种风格,你的代码会更容易被其他lisp程序员读取。分裂)
s在自己的行并不是大多数语言的眼睛的优势。如果你使用一个半正式的编辑器,它会有一些命令,它们了解平衡表达式,移动它们,切割,粘贴,移调等。因此,你不需要
The advantages of splitting )
s onto their own lines are not actually advantages in the eyes of most lispers. If you are using a half-decent editor it will have commands that understand balanced expressions, for moving across them, cutting, pasting, transposing, etc. So you don't need
) ; end of the loop
在您需要的范围内
# end of the loop
像Python这样的空白敏感语言
in some whitespace-sensitive language like Python
http://www.gnu.org/software/emacs/manual/html_node/emacs/ Expressions.html
这篇关于为什么通常在基于Lisp的语言中在一行上放置许多右括号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!