syntax - Racket(lisp 编程语言)中的 [ ] 和 ( ) 括号有什么区别?

标签 syntax racket brackets convention

在我看来,从技术上讲,两者是可以互换的,但具有不同的传统含义。

最佳答案

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/

相关文章:

python - 使用切片表示法反转列表

Scheme/DrRacket - 带 foldr 的 map 功能

scheme - 知道如何在 dr racket 中交错两个列表吗?

python - Statsmodels:ols 编写具有未知列名的公式

delphi - 为什么数组名称后面有括号和点而不是方括号?

c - C 中结构体定义的变体

jsf - Facelet异常: The value of attribute "value" associated with an element type "h:commandButton" must not contain the '<' character

racket - Racket 有依赖管理器吗?

html - 在 HTML/CSS 中使用多个 ID 为元素着色

Python:这里使用 [] 是什么意思?