diff options
| author | Juan Manuel Tomás <jtomas1815@gmail.com> | 2026-05-01 14:16:07 -0300 |
|---|---|---|
| committer | Juan Manuel Tomás <jtomas1815@gmail.com> | 2026-05-01 14:16:07 -0300 |
| commit | a4411bcc3919c2099934fd49664ee689460ebf80 (patch) | |
| tree | 524492a5febcd921528da7634ff91068b8c63d02 /def.lisp | |
| parent | d1816df4c029447f94963355cbdce5c434063ee6 (diff) | |
| download | utils-main.tar.gz utils-main.zip | |
Diffstat (limited to 'def.lisp')
| -rw-r--r-- | def.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/def.lisp b/def.lisp new file mode 100644 index 0000000..18fcd9e --- /dev/null +++ b/def.lisp @@ -0,0 +1,17 @@ +(in-package #:def) + +(defmacro defclass (name parents &body simple-slots) + (let (slots) + (dolist (slot simple-slots) + (if (symbolp slot) + (push `(,slot :initarg ,(intern (symbol-name slot) 'keyword) :accessor ,slot) slots) + (let ((slot-name (first slot)) + (slot-type (second slot)) + (slot-form (third slot))) + (cond ((and slot-type slot-form) + (push `(,slot-name :initarg ,(intern (symbol-name slot-name) 'keyword) :accessor ,slot-name :type ,slot-type :initform ,slot-form) slots)) + (slot-type + (push `(,slot-name :initarg ,(intern (symbol-name slot-name) 'keyword) :accessor ,slot-name :type ,slot-type) slots)) + (t + (push `(,slot-name :initarg ,(intern (symbol-name slot-name) 'keyword) :accessor ,slot-name) slots)))))) + `(cl:defclass ,name ,parents ,slots))) |
