diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-28 19:09:58 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-28 19:09:58 -0800 |
commit | 001147e1d3a37718c4b75c2d56ea475455707464 (patch) | |
tree | 6759908b1bd12d7a2f946deb49ed91118c05bfb0 /lib.h | |
parent | d12b6d6896a9838abd925feae34f6c01d535f223 (diff) | |
download | txr-001147e1d3a37718c4b75c2d56ea475455707464.tar.gz txr-001147e1d3a37718c4b75c2d56ea475455707464.tar.bz2 txr-001147e1d3a37718c4b75c2d56ea475455707464.zip |
seq_build: seq_pend must be nondestructive for lists.
Let's have both a seq_pend and seq_nconc, where seq_nconc
can reuse the pieces of list passed to it.
* lib.h (struct seq_build_ops): New member, nconc.
(seq_build_ops_init): Add nconc parameter and initializer.
(seq_nconc): Function declared.
* lib.c (seq_build_list_pend): Switch to list_collect_append,
otherwise mappend behaves destructively.
(seq_build_list_nconc): New function.
(sb_vec_ops, sb_str_ops, sb_buf_ops, sb_struct_ops,
sb_carray_ops): Use seq_build_generic_pend for nconc
operation.
(sb_list_ops): Use new seq_build_list_nconc for nconc
operation.
(sb_finished_ops): Use null pointer for nconc operation.
(seq_nconc): New function.
Diffstat (limited to 'lib.h')
-rw-r--r-- | lib.h | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -483,12 +483,13 @@ typedef struct seq_build { struct seq_build_ops { void (*add)(struct seq_build *, val); void (*pend)(struct seq_build *, val); + void (*nconc)(struct seq_build *, val); void (*finish)(struct seq_build *); void (*mark)(struct seq_build *); }; -#define seq_build_ops_init(add, pend, finish, mark) \ - { add, pend, finish, mark } +#define seq_build_ops_init(add, pend, nconc, finish, mark) \ + { add, pend, nconc, finish, mark } extern const seq_kind_t seq_kind_tab[MAXTYPE+1]; @@ -768,6 +769,7 @@ val iter_reset(val iter, val obj); void seq_build_init(val self, seq_build_t *bu, val likeobj); void seq_add(seq_build_t *bu, val item); void seq_pend(seq_build_t *bu, val items); +void seq_nconc(seq_build_t *bu, val items); val seq_finish(seq_build_t *bu); NORETURN val throw_mismatch(val self, val obj, type_t); INLINE val type_check(val self, val obj, type_t typecode) |