diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-13 20:23:35 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-13 20:23:35 -0700 |
commit | 378546295be6b3a72ee3792d9175501bc77c016d (patch) | |
tree | bafa7f54ab53ae1edb96cdce20165f4bdf18d88b /txr.1 | |
parent | 8b00ff477f752ea4e11290be398b5a3cf98cf7ab (diff) | |
download | txr-378546295be6b3a72ee3792d9175501bc77c016d.tar.gz txr-378546295be6b3a72ee3792d9175501bc77c016d.tar.bz2 txr-378546295be6b3a72ee3792d9175501bc77c016d.zip |
New function: macroexpand-struct-clause.
* stdlib/struct.tl (macroexpand-struct-clause): New function.
* autoload.c (struct_set_entries): Autoload struct module
on macroexpand-struct-clause.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 50 |
1 files changed, 50 insertions, 0 deletions
@@ -32313,6 +32313,56 @@ or a subtype thereof. fa.(write 4) -> ;; error: fa has no such method .brev +.coNP Function @ macroexpand-struct-clause +.synb +.mets (macroexpand-struct-clause < clause <> [ form ]) +.syne +.desc +If +.code clause +is a compound expression whose operator symbol was defined by +.code define-struct-clause +then +.code macroexpand-struct-clause +expands the clause and returns the expansion, which is +a list of zero or more clauses. +Otherwise, the function returns a one-element list containing the +.meta clause +argument, as if by the +.mono +.meti (list << clause ) +.onom +expression. + +The +.meta form +parameter, if present, is used for reporting errors. +Note: clauses are usually expanded during the processing of a +.code defstruct +macro; in that situation, the entire unexpanded +.code defstruct +form serves the role, + +.TP* Examples: + +.verb + ;; try to expand :delegate, using incorrect syntax. + (macroexpand-struct-clause '(:delegate x (a b))) + --> error "** source location n/a: nil: too few elements ..." + + ;; same, but with error reporting form. + (macroexpand-struct-clause '(:delegate x (a b)) '(abc xyz)) + --> error: "** expr-1:1: abc: too few elements ..." + + ;; correct :delegate syntax + (macroexpand-struct-clause '(:delegate x (a b) a.foo)) + --> ((:method x (a b) (qref a.foo (x b)))) + + ;; not a defstruct macro clause + (macroexpand-struct-clause '(1 2 3)) + -> ((1 2 3)) +.brev + .coNP Special variable @ *struct-clause-expander* .desc The |