2

The first tip in Warning Tips - GNU Emacs Lisp Reference Manual:

Try to avoid compiler warnings about undefined free variables, by adding dummy defvar definitions for these variables, like this: (defvar foo) Such a definition has no effect except to tell the compiler not to warn about uses of the variable foo in this file.

What is a scenario where someone would want no effect and yet want to disable the warning about the free variable? Whenever I got warnings about undefined free variables, it was always the case that either I forgot to put (defvar foo initvalue docstring) or I misspelled a local variable name.

4

1 回答 1

3

您的问题是为什么/何时禁止此类警告。答案是:在任何一种情况下:

  • 该变量在其他地方定义,并且您知道定义它的库将在代码实际尝试使用该变量之前加载。

  • 您要声明该变量是“特殊”变量,也就是说,它是动态绑定的,而不是词法绑定的。

于 2013-09-29T20:12:07.587 回答