summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/struct.tl16
1 files changed, 9 insertions, 7 deletions
diff --git a/share/txr/stdlib/struct.tl b/share/txr/stdlib/struct.tl
index 6bf665fb..8cd70359 100644
--- a/share/txr/stdlib/struct.tl
+++ b/share/txr/stdlib/struct.tl
@@ -27,12 +27,10 @@
(defun sys:bad-slot-syntax (arg)
(throwf 'eval-error "~s: bad slot syntax: ~s" 'defstruct arg))
- (defun sys:prune-nil-inits (slot-init-forms super-type)
- (remove-if (tb ((kind name init-form))
+ (defun sys:prune-missing-inits (slot-init-forms)
+ (remove-if (tb ((kind name : (init-form nil init-form-present)))
(and (member kind '(:static :instance :function))
- (null init-form)
- (or (not super-type)
- (not (slotp super-type name)))))
+ (not init-form-present)))
slot-init-forms)))
(defmacro defstruct (name-spec super . slot-specs)
@@ -105,8 +103,12 @@
:)))
((word name)
(caseq word
- ((:static :instance)
+ ((:static)
+ ^(,word ,name))
+ ((:instance)
^(,word ,name nil))
+ ((:method :function)
+ (sys:bad-slot-syntax slot))
(t ^(:instance ,word ,name))))
((name)
^(:instance ,name nil))
@@ -120,7 +122,7 @@
'defstruct super))))
(stat-si-forms [keep-if (op member @1 '(:static :function))
slot-init-forms car])
- (pruned-si-forms (sys:prune-nil-inits stat-si-forms super-type))
+ (pruned-si-forms (sys:prune-missing-inits stat-si-forms))
(func-si-forms [keep-if (op eq :function) pruned-si-forms car])
(val-si-forms [keep-if (op eq :static) pruned-si-forms car])
(inst-si-forms [keep-if (op eq :instance) slot-init-forms car])