为什么Lispers格式化他们的代码,如样例1所示,而不是如样例2所示? 对我来说(对于大多数来自不同编程背景的人而言,比Lisp),示例2中所示的格式将更容易阅读。 有没有什么特别的原因,Lispers喜欢样品1样式?
样品1
(defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))样品2
(defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1))) ) )Why do Lispers format their code like shown in sample 1 instead of as shown in sample 2? To me (and I guess, to most others coming from different programming backgrounds than Lisp), the formatting shown in sample 2 would be easier to read. Is there any particular reason why Lispers prefer the sample 1 style?
Sample 1
(defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))Sample 2
(defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1))) ) )最满意答案
LISP IDE环境往往会自动平衡括号,并根据嵌套级别管理缩进。 样本2在这些情况下没有带来任何好处。
在C / FORTRAN / Pascal遗产中,您倾向于强调排序排序(代码解析树更浅和更宽)。 范围结束在您的代码中是一个更重要的事件:因此重点已经在一定程度上更重要。
LISP IDE environments tend to balance parentheses automatically and manage indents based on nesting level. Sample 2 does not bring any advantages in those situations.
In the C/FORTRAN/Pascal heritage, you tend to emphasize sequencing over nesting (code parse trees are shallower and wider). End of scope is a more significant event in your code: hence emphasis has been and still to some extent is more important.
更多推荐
发布评论