Add defconstructor.

This commit is contained in:
Kyle 2015-04-10 02:19:20 -07:00
parent 35888b9b26
commit addde28629
3 changed files with 14 additions and 5 deletions

View File

@ -5,6 +5,7 @@
:author "K. Isom <kyle@metacircular.net>"
:license "MIT License"
:serial t
:depends-on (#:closer-mop)
:components ((:file "package")
(:file "on")
(:file "lol")

View File

@ -75,11 +75,18 @@ additional args provided to the lambda."
'()
(apply #'build-slot-list name slots)))
(args (build-arg-list slots)))
`(progn
(defclass ,name ,superclass
,slots
,docstring
,@body))))
`(defclass ,name ,superclass
,slots
,docstring
,@body)))
(defmacro defconstructor (class-name)
(let* ((class (find-class class-name))
(slot-list (when class
(mapcar #'closer-mop:slot-definition-name
(closer-mop:class-slots class)))))
`(defun ,(mksymb "make-" class-name) (&key ,@slot-list)
(make-instance ',class-name ,@(flatten (build-arg-list slot-list))))))
;;; hash-table functions.

View File

@ -15,6 +15,7 @@
#:mksymb
#:mkkw
#:defclass!
#:defconstructor
#:enable-hash-table-reader
#:hashkeys
#:sethash