Function: byte-compile-variadic-numeric

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

Signature

(byte-compile-variadic-numeric FORM)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/bytecomp.el.gz
;; Compile a pure function that accepts zero or more numeric arguments
;; and has an opcode for the binary case.
;; Single-argument calls are assumed to be numeric identity and are
;; compiled as (* x 1) in order to convert markers to numbers and
;; trigger type errors.
(defun byte-compile-variadic-numeric (form)
  (pcase (length form)
    (1
     ;; No args: use the identity value for the operation.
     (byte-compile-constant (eval form)))
    (2
     ;; One arg: compile (OP x) as (* x 1). This is identity for
     ;; all numerical values including -0.0, infinities and NaNs.
     (byte-compile-form (nth 1 form))
     (byte-compile-constant 1)
     (byte-compile-out (get '* 'byte-opcode) 0))
    (3
     (let ((arg1 (nth 1 form))
           (arg2 (nth 2 form)))
       (when (and (memq (car form) '(+ *))
                  (macroexp-const-p arg1))
         ;; Put constant argument last for better LAP optimization.
         (cl-rotatef arg1 arg2))
       (byte-compile-form arg1)
       (byte-compile-form arg2)
       (byte-compile-out (get (car form) 'byte-opcode) 0)))
    (_
     ;; >2 args: compile as a single function call.
     (byte-compile-normal-call form))))