# 9.2 定义符号(DONE)

定义(definition) 是一类特殊的 Lisp 表达式，该表达式用来指明某个符号的使用方式。当你定义一个符号时，你可以为这个符号提供一个初始值以及一段自解释的文档。

defvar 和 defconst 是两个特殊式，它们用来将符号定义为全局变量。顾名思义，全局变量是指，你可以在 Lisp 程序中的任何位置访问到这个变量。详情查阅 变量章。使用 defcustom 宏，可以定义 customizable 变量，而这个宏调用了 defvar 作为其子例程。（详情查阅 customization）

原则上说，你可以使用 setq 为任何一个符号指定一个变量值，不论该符号是否已经被定义为变量。不过，你需要为每一个你想使用的全局变量做变量定义，否则，在启用词法作用域时， Lisp 可能无法正确求值。

defun 将符号定义为函数。defun 首先创建一个 lambda 表达式，然后将其储存在符号的 function 部分内（术语“函数定义”，是指符号的function 部分），这个lambda表达式即为该符号的函数定义。（术语函数定义是指该符号function部分内储存的内容）defsubst 和 defalias 是另外两个定义函数的方法。详情查阅 函数章。

defmacro 将符号声明为宏。defmacro 创建一个宏对象，然后将其储存在符号的 function 部分内。需要注意的是，函数和宏共用了符号的 function 部分，因此不能使用同一个符号同时保存函数定义和宏定义，否则会出现命名冲突。详情查阅 宏章。

前面提到，Emacs Lisp 允许同一个符号同时声明为变量（使用 defvar）和函数（或宏）（使用 defun），这样的定义行为并不冲突。

这些定义还可以辅助编程。比如，C-h f 和 C-h v 命令创建帮助 buffer，用来检查符号的详细信息。详情查阅 The GNU Emacs Manual 的 Name Help 中。（注意，不是本文档，本文档是Elisp Manual）


---

# 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/fu-hao/9.2-fu-hao-sheng-ming.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.
