Function: cl-generic-define
cl-generic-define is a byte-compiled function defined in
cl-generic.el.gz.
Signature
(cl-generic-define NAME ARGS OPTIONS)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-generic.el.gz
;;;###autoload
(defun cl-generic-define (name args options)
(pcase-let* ((generic (cl-generic-ensure-function name 'noerror))
(`(,spec-args . ,_) (cl--generic-split-args args))
(mandatory (mapcar #'car spec-args))
(apo (assq :argument-precedence-order options)))
(unless (fboundp name)
;; If the generic function was fmakunbound, throw away previous methods.
(setf (cl--generic-dispatches generic) nil)
(setf (cl--generic-method-table generic) nil))
(when apo
(dolist (arg (cdr apo))
(let ((pos (memq arg mandatory)))
(unless pos (error "%S is not a mandatory argument" arg))
(let* ((argno (- (length mandatory) (length pos)))
(dispatches (cl--generic-dispatches generic))
(dispatch (or (assq argno dispatches) (list argno))))
(setf (cl--generic-dispatches generic)
(cons dispatch (delq dispatch dispatches)))))))
(setf (cl--generic-options generic) options)
(cl--generic-make-function generic)))