From f9298daa51f5800f31ee7cdca5797ee57ae2e163 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 3 Nov 2022 20:28:27 -0700 Subject: New feature: struct preludes. A struct prelude definition associates one or more future defstruct (by struct name) with clauses which are implicitly inserted into the defstruct. It is purely a macro-time construct, customizing the expansion behavior of defstruct. * stdlib/struct.tl (*struct-prelude, *struct-prelude-alists*): New special variables holding hash tables. (defstruct): Before processing slot-specs, augment it with the contents of the prelude definitions associated with this struct name. (define-struct-prelude): New macro. * autoload.c (struct_set_entries): define-struct-prelude is interned and triggers autoload of struct module. * tests/012/oop-prelude.tl: New file. * tests/012/oop-prelude.expected: Likewise. * txr.1: Documented. * stdlib/doc-syms.tl: Updated. --- autoload.c | 1 + 1 file changed, 1 insertion(+) (limited to 'autoload.c') diff --git a/autoload.c b/autoload.c index 7a6cd79d..30d388ba 100644 --- a/autoload.c +++ b/autoload.c @@ -220,6 +220,7 @@ static val struct_set_entries(val fun) lit("defstruct"), lit("qref"), lit("uref"), lit("new"), lit("lnew"), lit("new*"), lit("lnew*"), lit("meth"), lit("umeth"), lit("usl"), lit("defmeth"), lit("rslot"), + lit("define-struct-prelude"), lit("define-struct-clause"), lit("macroexpand-struct-clause"), nil }; val vname[] = { -- cgit v1.2.3