Function: cl-struct-slot-value

cl-struct-slot-value is a byte-compiled function defined in cl-macs.el.gz.

Signature

(cl-struct-slot-value STRUCT-TYPE SLOT-NAME INST)

Documentation

Return the value of slot SLOT-NAME in INST of STRUCT-TYPE.

STRUCT-TYPE and SLOT-NAME are symbols. INST is a structure instance.

View in manual

Probably introduced at or before Emacs version 25.1.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-macs.el.gz
;; Additional functions that we can now define because we've defined
;; `cl-defsubst' and `cl-typep'.

(define-inline cl-struct-slot-value (struct-type slot-name inst)
  "Return the value of slot SLOT-NAME in INST of STRUCT-TYPE.
STRUCT-TYPE and SLOT-NAME are symbols.  INST is a structure instance."
  (declare (side-effect-free t))
  (inline-letevals (struct-type slot-name inst)
    (inline-quote
     (progn
       (unless (cl-typep ,inst ,struct-type)
         (signal 'wrong-type-argument (list ,struct-type ,inst)))
       ;; We could use `elt', but since the byte compiler will resolve the
       ;; branch below at compile time, it's more efficient to use the
       ;; type-specific accessor.
       (if (eq (cl-struct-sequence-type ,struct-type) 'list)
           (nth (cl-struct-slot-offset ,struct-type ,slot-name) ,inst)
         (aref ,inst (cl-struct-slot-offset ,struct-type ,slot-name)))))))