diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2024-02-27 21:08:14 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2024-02-27 21:08:14 -0800 |
commit | fb09dfc8559a5b01c75b691613cf9eda54f7bee5 (patch) | |
tree | dc54324ff4f6210606eec3d8f1be85b094cfe27b /stdlib/save-exe.tl | |
parent | 1291aa76a9c85ac50bc5ebe968fd332bdfe80af0 (diff) | |
download | txr-fb09dfc8559a5b01c75b691613cf9eda54f7bee5.tar.gz txr-fb09dfc8559a5b01c75b691613cf9eda54f7bee5.tar.bz2 txr-fb09dfc8559a5b01c75b691613cf9eda54f7bee5.zip |
seq_build: support improper lists.
To be useful for some operations, the seq_build framework
must handle the pend operation on lists specially.
The appended piece must only be treated as a sequence if
it is a cons. Moreover, if it is an atom, or of it is
an improper list, then the list terminates. Subsequent
add and pend operations must fail. The atom must appear
as the terminator. We meet these objectives by switching
the object's operations, sb_list_ops, to a new set of
operations, sb_improper_ops.
* lib.c (seq_build_list_pend): New static function.
This individually adds all items from the input
list, until it hits a terminating atom. If the
atom isn't nil, it converts the seq_build_t object
to improper operations.
(seq_build_improper_add, seq_build_improper_pend):
New static functions. These throw an error:
adding anything to an improper list is impossible.
(seq_build_improper_finish): New function, which
does nothing: the improper list is finished already.
(sb_list_ops): Use the seq_build_list_pend operation
rather than the generic one.
(sb_improper_ops): New static structure.
(seq_build_convert_to_improper): New static function.
Finishes the list, giving it the specified terminating
atom, and then switches to sb_improper_ops so that
adding is no longer possible.
Diffstat (limited to 'stdlib/save-exe.tl')
0 files changed, 0 insertions, 0 deletions