Function: byte-compile-defvar

byte-compile-defvar is a byte-compiled function defined in bytecomp.el.gz.

Signature

(byte-compile-defvar FORM)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
(defun byte-compile-defvar (form)
  ;; This is not used for file-level defvar/consts.
  (when (and (symbolp (nth 1 form))
             (not (string-match "[-*/:$]" (symbol-name (nth 1 form))))
             (byte-compile-warning-enabled-p 'lexical (nth 1 form)))
    (byte-compile-warn "global/dynamic var `%s' lacks a prefix"
                       (nth 1 form)))
  (byte-compile-docstring-length-warn form)
  (let ((fun (nth 0 form))
	(var (nth 1 form))
	(value (nth 2 form))
	(string (nth 3 form)))
    (byte-compile-set-symbol-position fun)
    (when (or (> (length form) 4)
	      (and (eq fun 'defconst) (null (cddr form))))
      (let ((ncall (length (cdr form))))
	(byte-compile-warn
	 "`%s' called with %d argument%s, but %s %s"
	 fun ncall
	 (if (= 1 ncall) "" "s")
	 (if (< ncall 2) "requires" "accepts only")
	 "2-3")))
    (push var byte-compile-bound-variables)
    (if (eq fun 'defconst)
	(push var byte-compile-const-variables))
    (when (and string (not (stringp string)))
      (byte-compile-warn "third arg to `%s %s' is not a string: %s"
                         fun var string))
    (byte-compile-form-do-effect
     (if (cddr form)  ; `value' provided
         ;; Quote with `quote' to prevent byte-compiling the body,
         ;; which would lead to an inf-loop.
         `(funcall '(lambda (,byte-compile-tmp-var)
                      (,fun ,var ,byte-compile-tmp-var ,@(nthcdr 3 form)))
                   ,value)
        (if (eq fun 'defconst)
            ;; This will signal an appropriate error at runtime.
            `(eval ',form)
          ;; A simple (defvar foo) just returns foo.
          `',var)))))