# 2.4.6.2 点对记法

点对记法 是更加通用，正式的点对记法。这种记法显示的声明了 CAR 和 CDR 部分。使用这种语法，(a . b) 表示一个点对，其中 CAR 部分储存 对象 a，CDR 部分储存 对象b。点对记法之所以比列表记法更加通用，是因为 CDR 部分所指的并不一定是列表。不过点对记法通常会更繁琐一些。比如 '(1 2 3)' 会被写成 '(1 . (2 . (3 . nil)))' 。对于 nil 结尾的列表，列表记法通常更加简洁清爽。当你打印一个列表时，当且仅当点对的 CDR 不是列表的时候，Lisp 才会采用点对记法。

这里有一个点对可视化的例子：

```
    --- ---
   |   |   |--> violet
    --- ---
     |
     |
      --> rose
```

你还可以把点对记法和列表记法融合起来使用，这样可以很好的展示一个 结尾 CDR 非nil 的点对链。比如，(rose violet . buttercup) 和 (rose . (violet . buttercup))就是等价的。这个列表看起来像这样：

```
    --- ---      --- ---
   |   |   |--> |   |   |--> buttercup
    --- ---      --- ---
     |            |
     |            |
      --> rose     --> violet
```

不过 (rose . violet . buttercup) 这种记法是不合理的。如果要解释成 buttercup 处在 CDR 位置，那显然是不合理的，因为 CDR 部分已经被 violet 占着了。

列表 (rose violet) 和 这个是等价的 (rose . (violet))，而且它们都像下图这样：

```
    --- ---      --- ---
   |   |   |--> |   |   |--> nil
    --- ---      --- ---
     |            |
     |            |
      --> rose     --> violet
```

类似的，这个包含 3 个元素的列表 (rose violet buttercup) 和 这个是等价的 (rose . (violet . (buttercup)))。它们看起来是这样的：

```
    --- ---      --- ---      --- ---
   |   |   |--> |   |   |--> |   |   |--> nil
    --- ---      --- ---      --- ---
     |            |            |
     |            |            |
      --> rose     --> violet   --> buttercup
```

2021-8-19  1:18


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://emacs-lisp.ivory.cafe/lisp-shu-ju-lei-xing/bian-cheng-lei-xing/2.4.6-dian-dui-lei-xing/2.4.6.2-dian-dui-ji-fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
