修复Lisp语法 [英] Fixing Lisp Syntax
问题描述
成为Lisp的新手,我想知道Lisp语法是否可以修复"?
Being a newbie to Lisp I'm wondering if the Lisp syntax could be "fixed"?
有人说Lisp的语法是其最大的优点之一.我不太明白这一点.
Some people say the syntax in Lisp is one of its biggest strengths. I don't quite understand this.
用空白,换行和缩进的组合来代替明显的"括号是不可能的吗?就像在Python中一样?
Isn't it possible to replace "obvious" parentheses with a combination of white spaces, new lines and indenting? Just like in Python?
在我看来,括号是Lisp代码中最常用的字符.我想知道这是否是正确的-但是如果是这样,这是否暗示语法有一些冗余?
It looks to me like parentheses are the most used characters in Lisp code. I'm wondering if that's true - but if it is, isn't this a suggestion, that there is some redundancy in the syntax?
这个问题是否有一些简单的答案-为什么会有这么多括号?
Is there some simple answer to the question - why so many parentheses?
例如:
(defun factorial (x)
(if (= x 0)
1
(* x
(factorial (- x 1)))))
为什么不呢?
defun factorial (x)
if (= x 0)
1
* x
factorial
- x 1
例如在行的结尾处关闭括号,并始终在新行中将其打开. 只有1会是模棱两可的-是1还是(1)-但是我们可以引入一个例外-单个标记未列出".
e.g. close parentheses at the end of line, and always open them on new lines. Only the 1 would be ambiguous - is it 1 or (1) - but we could introduce an exception - single tokens are not "listified".
这行得通吗?
谢谢大家!我现在看到在lispin
Thank you all! I see now there are some links at the lispin site.
推荐答案
您建议的内容似乎已在 Lispin
What you suggest appears to have been implemented in Lispin
编辑: sindikat 在下面的注释中指出该链接不再有效.这是Web存档中该站点的最后一个有效版本: http://wayback.archive.org/web/20080517144846id_/http://www.lispin.org/
sindikat points out in the comments below that the link is no longer valid. Here's the last valid version of the site from the Web Archive: http://wayback.archive.org/web/20080517144846id_/http://www.lispin.org/
这篇关于修复Lisp语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!