diff options
author | colin <colin@cicadas.surf> | 2024-06-19 10:03:12 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2024-06-19 10:03:12 -0700 |
commit | daff1c772475c096760c82d6eef2fae3dad001cb (patch) | |
tree | 8bfb5efe40c2aeede0cda6ee89bc0319dbde0ac2 | |
parent | 5822dcfcfec66596bd4745e6f8450e6a824f6082 (diff) |
Add: :noarg flag to def:class
-rw-r--r-- | def.lisp | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -47,6 +47,7 @@ have an value after them, all flags must come before other options. Flags are: :prefix - prefix the accessor by the class name :ro - only define a reader :wo - only define a writer + :noarg - means no initarg By default an accessor is defined. @@ -64,14 +65,15 @@ E.g. (intern (format nil "~a-~a" name slot)) slot)) (singlep (x) - (find x '(:prefix :ro :wo) :test #'eq)) + (find x '(:prefix :ro :wo :noarg) :test #'eq)) (parse-slot-spec-expr (expr) " (names ... &key kwargs)" (multiple-value-bind (slot-names kwargs) (take-until #'keywordp expr) (multiple-value-bind (singles kwargs) (partition #'singlep kwargs) (let ((prefix-accessor? (find ':prefix singles :test #'eq)) (read-only? (find ':ro singles :test #'eq)) - (write-only? (find ':wo singles :test #'eq))) + (write-only? (find ':wo singles :test #'eq)) + (no-arg? (find ':noarg singles :test #'eq))) (assert (not (and read-only? write-only?)) () "A slot cannot be both read-only (:ro) and write-only (:wo).") (loop @@ -81,7 +83,8 @@ E.g. :for slot :in slot-names :collect `(,slot ,accessor-type ,(make-accessor-name slot prefix-accessor?) - :initarg ,(alexandria:make-keyword slot) + ,@(unless no-arg? + (list :initarg (alexandria:make-keyword slot))) ,@kwargs)))))) (parse-class-options (kwargs) |