Function: slot-exists-p

slot-exists-p is a byte-compiled function defined in eieio.el.gz.

Signature

(slot-exists-p OBJECT-OR-CLASS SLOT)

Documentation

Return non-nil if OBJECT-OR-CLASS has SLOT.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/eieio.el.gz
(defun slot-exists-p (object-or-class slot)
  "Return non-nil if OBJECT-OR-CLASS has SLOT."
  (let ((cv (cond ((eieio-object-p object-or-class)
                   (eieio--object-class object-or-class))
                  ((eieio--class-p object-or-class) object-or-class)
                  (t (find-class object-or-class 'error)))))
    (or (gethash slot (eieio--class-index-table cv))
        ;; FIXME: We could speed this up by adding class slots into the
        ;; index-table (e.g. with a negative index?).
	(let ((cs (eieio--class-class-slots cv))
	      found)
	  (dotimes (i (length cs))
	    (if (eq slot (cl--slot-descriptor-name (aref cs i)))
		(setq found t)))
	  found))))