+(define-layered-function attribute-value (instance attribute)
+ (:documentation " Like SLOT-VALUE for instances, the base method calls GETTER."))
+
+(define-layered-method attribute-value (instance (attribute standard-attribute))
+ (with-slots (getter slot-name) attribute
+ (cond ((and (slot-boundp attribute 'getter) getter)
+ (funcall getter instance))
+ ((and (slot-boundp attribute 'slot-name) slot-name)
+ (when (slot-boundp instance slot-name)
+ (slot-value instance slot-name)))
+ ((and (slot-exists-p instance (attribute.name attribute)) )
+ (when (slot-boundp instance (attribute.name attribute))
+ (slot-value instance (attribute.name attribute)))))))
+
+(define-layered-function (setf attribute-value) (value instance attribute))
+
+(define-layered-method
+ (setf attribute-value) (value instance (attribute standard-attribute))
+ (with-slots (setter slot-name) attribute
+ (cond ((and (slot-boundp attribute 'setter) setter)
+
+ (funcall setter value instance))
+ ((and (slot-boundp attribute 'slot-name) slot-name)
+ (setf (slot-value instance slot-name) value))
+ ((and (slot-exists-p instance (attribute.name attribute)) slot-name)
+ (setf (slot-value instance (attribute.name attribute)) value))
+ (t
+ (error "Cannot set ~A in ~A" attribute instance)))))