diff options
| author | 2025-10-18 07:31:03 +0300 | |
|---|---|---|
| committer | 2025-10-18 07:31:03 +0300 | |
| commit | f4b8d8e58b82b29b3cc765c44045b86d6ec44054 (patch) | |
| tree | 331be6aa8104328e14f42b4077345e8ef86b1433 /src/tg/method-macros.lisp | |
| parent | fixmeup (diff) | |
| download | ukkoclot-f4b8d8e58b82b29b3cc765c44045b86d6ec44054.tar.gz ukkoclot-f4b8d8e58b82b29b3cc765c44045b86d6ec44054.tar.xz ukkoclot-f4b8d8e58b82b29b3cc765c44045b86d6ec44054.zip | |
Utilise alexandria:with-gensyms
Diffstat (limited to 'src/tg/method-macros.lisp')
| -rw-r--r-- | src/tg/method-macros.lisp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/tg/method-macros.lisp b/src/tg/method-macros.lisp index 215b2ab..b924e15 100644 --- a/src/tg/method-macros.lisp +++ b/src/tg/method-macros.lisp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | (defpackage :ukkoclot/tg/method-macros | 3 | (defpackage :ukkoclot/tg/method-macros |
| 4 | (:documentation "Macros for easy defining TG methods.") | 4 | (:documentation "Macros for easy defining TG methods.") |
| 5 | (:use :c2cl :iterate) | 5 | (:use :c2cl :iterate) |
| 6 | (:import-from :alexandria :with-gensyms) | ||
| 6 | (:import-from :com.dieggsy.f-string :enable-f-strings) | 7 | (:import-from :com.dieggsy.f-string :enable-f-strings) |
| 7 | (:import-from :serapeum :take) | 8 | (:import-from :serapeum :take) |
| 8 | (:import-from :ukkoclot/state :bot) | 9 | (:import-from :ukkoclot/state :bot) |
| @@ -51,13 +52,11 @@ | |||
| 51 | `(,(param-name param) ,(param-default param))) | 52 | `(,(param-name param) ,(param-default param))) |
| 52 | 53 | ||
| 53 | (defun emit-defun (name return-type params method) | 54 | (defun emit-defun (name return-type params method) |
| 54 | (let ((revparams (reverse params)) | 55 | (with-gensyms (args bot) |
| 55 | (args (gensym "ARGS")) | ||
| 56 | (bot (gensym "BOT"))) | ||
| 57 | `(defun ,name (,bot &key ,@(iter (for param in params) ; lint:suppress lambda-list-invalid | 56 | `(defun ,name (,bot &key ,@(iter (for param in params) ; lint:suppress lambda-list-invalid |
| 58 | (collect (emit-defun-arg param)))) | 57 | (collect (emit-defun-arg param)))) |
| 59 | (let (,args) | 58 | (let (,args) |
| 60 | ,@(iter (for param in revparams) | 59 | ,@(iter (for param in (reverse params)) |
| 61 | (collect (if (param-skip-if-default param) | 60 | (collect (if (param-skip-if-default param) |
| 62 | `(unless (equal ,(param-name param) | 61 | `(unless (equal ,(param-name param) |
| 63 | ,(param-default param)) | 62 | ,(param-default param)) |