get-slot-by-name, get-slot-of-by-name.
Thu Aug 23 07:17:36 PDT 2007 Ryszard Szopa <ryszard.szopa@gmail.com>
* get-slot-by-name, get-slot-of-by-name.
diff -rN -u old-mop-utils/mop-utils.lisp new-mop-utils/mop-utils.lisp
--- old-mop-utils/mop-utils.lisp 2014-07-12 21:54:36.000000000 -0700
+++ new-mop-utils/mop-utils.lisp 2014-07-12 21:54:36.000000000 -0700
@@ -4,7 +4,7 @@
(defpackage mop-utils
(:documentation "A set of Metaobject Protocol utilities.")
(:use :cl #+sbcl :sb-mop #-sbcl :closer-mop)
- (:export #:defmetaclass #:class-name-of #:slots-of #:slot-names-of))
+ (:export #:defmetaclass #:class-name-of #:slots-of #:slot-names-of #:get-slot-of-by-name #:get-slot-by-name))
(in-package :mop-utils)
@@ -76,3 +76,9 @@
(defun slots-of (object)
"List of slots of OBJECT."
(class-slots (class-of object)))
+
+(defun get-slot-by-name (class name)
+ (find-if (lambda (slot) (eql (slot-definition-name slot) name)) (class-slots class)))
+
+(defun get-slot-of-by-name (object name)
+ (get-slot-by-name (class-of object) name))