Skip to content

Instantly share code, notes, and snippets.

@rigidus
Created July 31, 2012 10:50
Show Gist options
  • Save rigidus/3216053 to your computer and use it in GitHub Desktop.
Save rigidus/3216053 to your computer and use it in GitHub Desktop.
(defclass my-metaclass (standard-class)
((slot-metaclass :initform nil
:initarg :slot-metaclass
:accessor slot-metaclass))
(:documentation "metaclass"))
(defmethod validate-superclass ((class my-metaclass) (super-class standard-class))
t)
(defmethod make-instance ((class direct-my-arg-slot) &rest initargs &key my-arg)
(error "123213213"))
(defclass direct-my-arg-slot (standard-direct-slot-definition)
((my-arg :initarg :my-arg :reader my-arg))
(:documentation "Type of slots expanded my-arg"))
(defmethod direct-slot-definition-class ((class my-metaclass) &rest initargs &key my-arg &allow-other-keys)
(declare (ignore initargs))
(if my-arg
(find-class 'direct-my-arg-slot)
(call-next-method)))
(defclass my-class ()
((slot-class :initform nil
:my-arg :the-arg
:initarg :slot-class
:accessor :slot-class))
(:metaclass my-metaclass))
(make-instance 'my-class :slot-class "111")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment