summaryrefslogtreecommitdiff
path: root/def.lisp
diff options
context:
space:
mode:
authorJuan Manuel Tomás <jtomas1815@gmail.com>2026-05-01 14:16:07 -0300
committerJuan Manuel Tomás <jtomas1815@gmail.com>2026-05-01 14:16:07 -0300
commita4411bcc3919c2099934fd49664ee689460ebf80 (patch)
tree524492a5febcd921528da7634ff91068b8c63d02 /def.lisp
parentd1816df4c029447f94963355cbdce5c434063ee6 (diff)
downloadutils-a4411bcc3919c2099934fd49664ee689460ebf80.tar.gz
utils-a4411bcc3919c2099934fd49664ee689460ebf80.zip
Update librariesHEADmain
Diffstat (limited to 'def.lisp')
-rw-r--r--def.lisp17
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)))