elisp中的下划线(_)是什么意思?

clo*_*n21 9 emacs lambda elisp naming-conventions

我正在审查emacs包中的neotree包代码.我不知道下面宏定义中下划线(_)的含义.

(lambda(&rest _))

宏的完整定义如下.

(defmacro neotree-make-executor (&rest fn-form)
  "Make an open event handler, FN-FORM is event handler form."
  (let* ((get-args-fn
          (lambda (sym) (or (plist-get fn-form sym) (lambda (&rest _)))))
         (file-fn (funcall get-args-fn :file-fn))
         (dir-fn (funcall get-args-fn :dir-fn)))
    `(lambda (&optional arg)
       (interactive "P")
       (neo-global--select-window)
       (neo-buffer--execute arg ,file-fn ,dir-fn))))
Run Code Online (Sandbox Code Playgroud)

abo*_*abo 16

下划线是有效的符号名称.字节编译器的约定是未使用的参数名称应以下划线开头,以避免编译期间出现"未使用的词法变量"警告.


clo*_*n21 5

参考elisp 参考手册

11.9.4 使用词法绑定...

lexical-binding [Variable]
    If this buffer-local variable is non-nil, Emacs Lisp files and buffers are evaluated
    using lexical binding instead of dynamic binding. (However, special variables are still
    dynamically bound; see below.) If nil, dynamic binding is used for all local variables.
    This variable is typically set for a whole Emacs Lisp file, as a file local variable (see
    Section 11.11 [File Local Variables], page 163). Note that unlike other such variables,
    this one must be set in the first line of a file.
Run Code Online (Sandbox Code Playgroud)

...

(To silence byte-compiler warnings about unused variables, just use a variable name that
start with an underscore. The byte-compiler interprets this as an indication that this is a
variable known not to be used.)
Run Code Online (Sandbox Code Playgroud)