ref: 6d0239c3d0f114b3cf71f4420868afd7e3290d0c
parent: 367b98c686a8d044e09f7cf518db7ff8e5d17753
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Apr 17 02:00:58 EDT 2025
defstruct: simplify :named handling
--- a/boot/sl.boot
+++ b/boot/sl.boot
@@ -18,8 +18,7 @@
(data :size
decompressed-bytes)) defstruct ((name
doc options… (slot-1 DEFAULT) slot-2 (slot-3 :read-only))
- (name (:type 'vec) (:named NIL) (:constructor T) (:conc-name NIL) (:predicate T))) compare ((x
- y)) buffer (NIL) num? ((v)) add-exit-hook ((fun)) rand-float (NIL) builtin? ((v)) set-car! ((cell
+ (name (:type 'vec) (:named T) (:constructor T) (:conc-name NIL) (:predicate T))) compare ((x y)) buffer (NIL) num? ((v)) add-exit-hook ((fun)) rand-float (NIL) builtin? ((v)) set-car! ((cell
new-first)) cons? ((v)) doc-group ((group-name doc)) 1+ ((n)) aref ((sequence subscript0)) zero? ((x)) vec (NIL) >= ((a)) sym? ((v)) void? ((x)) length= ((seq
n)) positive? ((x)) doc-for ((term)) aset! ((sequence subscripts… new-value)) car ((lst)) <= ((a)) str (NIL) cons ((first
second)) - ((a)) remprop ((symbol key)) negative? ((x)) rand (NIL) void (NIL) file ((path
@@ -77,7 +76,7 @@
#fn(get) *properties* :kind *doc-extra* filter #fn("n10<20Q:" #(:doc-fmt))
#fn("n10<20Q:" #(:doc-see)) princ foldl #fn("n20=161:") newline "See also:" #fn("n1A<0=700=21522263:" #(getprop
*formals-list* " ")) "Members:" #fn("n1A<070021522263:" #(getprop *formals-list* " ")) void
- "no help for " #fn(str) " " "" " (undefined)")) defstruct #fn("O10005000*///z6W1000J7021?14W2000;J60q?24W3000J60D?34W4000J60q?44W5000;J60D?54IIb=228=230>1_5142224?>5147586518?<8?=268A5127288A528>8A51121C60D@C0129C60q@907:2;1528E3T08;S;J70482DQ360q@807:2<51;J404D@4082;36040e185DQ;3:042=02>52;J504858G;3L048F3708G@A08<3;07:2?51@30q8E3:02@0e2@7002Ae283DQ83;3\\0483H;3M0483DQ;3:042=2B052;J504838DP;J5048384;J:042C02D52II222E8E18F8K848<8G08A>9?M514222F8E108C8F>5?N5148@3G07G02H8@2I8MPe15252@30q42J2Ke18H3{02L8H2Me28E3E02N2O2Me22P8Ie2e3@V02Q2R2S2MEe32P0e2e32T2U2Me27V8B51e3e3e3@30qe18K3C02L8K<8N8K=51e3@30qe18E3U02W2P0e22P2Xe28J3808K<@808N8D51e4@30qe12Y7Z2[8=8D8C8L8E8H8I8F0>98B525165:" #(#(:constructor
+ "no help for " #fn(str) " " "" " (undefined)")) defstruct #fn("O10005000*///z6W1000J7021?14W2000;J60D?24W3000J60D?34W4000J60q?44W5000;J60D?54IIb=228=230>1_5142224?>5147586518?<8?=268A5127288A528>8A51121C60D@C0129C60q@907:2;1528E3B082;J9047:2<51@;082;35048;;36040e185DQ;3:042=02>52;J504858G;3L048F3708G@A08<3;07:2?51@30q8E3:02@0e2@7002Ae283DQ83;3\\0483H;3M0483DQ;3:042=2B052;J504838DP;J5048384;J:042C02D52II222E8E18F8K848<8G08A>9?M514222F8E108C8F>5?N5148@3G07G02H8@2I8MPe15252@30q42J2Ke18H3{02L8H2Me28E3E02N2O2Me22P8Ie2e3@V02Q2R2S2MEe32P0e2e32T2U2Me27V8B51e3e3e3@30qe18K3C02L8K<8N8K=51e3@30qe18E3U02W2P0e22P2Xe28J3808K<@808N8D51e4@30qe12Y7Z2[8=8D8C8L8E8H8I8F0>98B525165:" #(#(:constructor
2 :predicate 4 NIL NIL :type 0 :named 1 :conc-name 3 NIL NIL) vec #0#
#fn("n17005121220A>28552485:" #(cddr #fn(for-each)
#fn("n17002152340q:722324A<25F2605661:" #(member (:read-only)
--- a/src/system.sl
+++ b/src/system.sl
@@ -1064,7 +1064,7 @@
(error "no default constructor for struct: " struct))))
(defmacro (defstruct name (:type 'vec)
- (:named NIL named-supplied)
+ (:named T named-supplied)
(:constructor T)
(:conc-name NIL)
(:predicate T predicate-supplied)
@@ -1152,10 +1152,8 @@
(arg-error "invalid struct type: " type)))]
; should the struct name appear as the first element?
[named (and (if isvec
- (or (unless (or (not named-supplied) (eq? named T))
- (arg-error "structs of type `vec` are always :named T"))
- T)
- named)
+ (or named (arg-error "structs of type `vec` are always :named T"))
+ (and named named-supplied))
(list name))]
; struct's predicate name
[predicate (or (and (eq? predicate T)