diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-26 22:22:30 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-26 22:22:30 -0800 |
commit | 4a5554fad4cf85a3744baed1234164159ece310a (patch) | |
tree | 754fb38d0995a36544ba85bc4d7ddaa79b8f8348 /stdlib/ver.txr | |
parent | 75756b537ed10528744d452fa516f4fba0437aa2 (diff) | |
download | txr-4a5554fad4cf85a3744baed1234164159ece310a.tar.gz txr-4a5554fad4cf85a3744baed1234164159ece310a.tar.bz2 txr-4a5554fad4cf85a3744baed1234164159ece310a.zip |
New sequence building framework.
Just as the "seq_iter" iterators help to condense
the code for iterating any kind of sequence, "seq_builder"
objects solve the problem of producing a sequence of the
same kind as an input sequence.
Until now, two approaches have been taken for this. One
was to have separately coded cases: code iterating over
a string building up a string, and so on. The other has
been to produce a list, which is then coerced to the
right sequence type using make_like.
The approach introduced here is similar to using
make_like, but without wastefully consing up a temporary
list.
The remove-if, remqual, remql, remq and keep-if functions
are retargetted to this new abstraction.
* lib.h (struct seq_build, seq_build_t): New struct type.
(struct seq_build_ops): New struct type.
(seq_build_ops_init): New macro.
(seq_build_init, seq_add, seq_pend, seq_finish): Functions
declared.
* lib.c (seq_build_generic_pend, seq_build_obj_mark,
seq_build_struct_mark, seq_build_carray_mark,
seq_build_vec_add, seq_build_str_add, seq_build_buf_add,
seq_build_buf_pend, seq_build_buf_finish, seq_build_list_add,
seq_build_list_finish, seq_build_struct_finish,
seq_build_carray_finish): New static functions.
(sb_vec_ops, sb_str_ops, sb_buf_ops, sb_struct_ops,
sb_carray_ops, sb_list_ops): New static structs.
(seq_build_init, seq_add, seq_pend, seq_finish): New
functions.
(rem_impl, rem_if_impl): Reworked in terms of seq_iter
and seq_build, becoming much shorter, and handling all
iterable objects.
Diffstat (limited to 'stdlib/ver.txr')
0 files changed, 0 insertions, 0 deletions