在我看来,从技术上讲,两者是可以互换的,但具有不同的传统含义。
最佳答案
According to the Racket documentation , 没有区别——只有一个约定使用 [
和 ]
为 cond
条款(就我的理解,其余部分使用您的判断):
The use of square brackets for cond clauses is a convention. In Racket, parentheses and square brackets are actually interchangeable, as long as ( is matched with ) and [ is matched with ]. Using square brackets in a few key places makes Racket code even more readable.
在对 Racket 语言的设计一无所知的情况下,我的猜测是引入方括号是为了回应许多 Lisp 表达式由于大量相同的括号而难以阅读的提示,特别是在括号的末尾深层嵌套的结构。换句话说,它可能用于让您的眼睛轻松地在代码中建立一些引用点,以识别您在任何给定点关闭的括号。
关于syntax - Racket(lisp 编程语言)中的 [ ] 和 ( ) 括号有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41417892/