aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Pouar <pouar@pouar.net>2020-07-15 13:08:25 -0500
committerGravatar Pouar <pouar@pouar.net>2020-07-15 13:08:25 -0500
commitac985575bf1d5bebec0a8c8141c00da44acea580 (patch)
treec87775c1eaffc41e7f88840ae99cc4339d8f6c3a
parentexport yadfa:element-type (diff)
allow more variations of yadfa:defmatch
-rw-r--r--core/libexec.lisp9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/libexec.lisp b/core/libexec.lisp
index 4a1d4a7..de209f7 100644
--- a/core/libexec.lisp
+++ b/core/libexec.lisp
@@ -154,9 +154,12 @@
(or (eq attack t) (not (typep (get-move attack character) '(or mess-move-mixin wet-move-mixin))))))
(defmacro defmatch (source target &body return)
(flet ((arg (arg sym)
- (if (typep arg '(and list (not null)))
- arg
- (list (a:make-gensym sym) arg))))
+ (typecase arg
+ ((and list (not null)) arg)
+ (null (a:make-gensym sym))
+ ((eql t) `(,(a:make-gensym sym) element-type))
+ ((and symbol (not keyword)) `(,(a:make-gensym sym) ,arg))
+ (t (error 'simple-error :format-control "Invalid argument ~s" :format-arguments `(,arg))))))
`(progn (defmethod type-match (,(arg source 'source)
,(arg target 'target))
,@return)