From d12b6d6896a9838abd925feae34f6c01d535f223 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 28 Feb 2024 08:46:18 -0800 Subject: seq_build: convert list buiding to list_collect. We want to use the list_collect functions for consistency. For instance, these functions allow an atom to be added to an improper list if the terminating atom is a sequence. (append '(1 . "abc") "d") yields (1 . "abcd"). * lib.h (struct seq_build): New member, tail. * lib.c (seq_build_list_add): Use list_collect. (seq_build_list_pend): Use list_collect_nconc. (seq_build_list_finish): Nothing to do here, except call seq_build_convert_to_finished since bu->obj is the head of the list at all times now. (seq_build_improper_add, seq_build_improper_pend): Functions removed. (sb_improper_ops): Structure removed. (seq_build_convert_to_improper): Function removed. (seq_build_convert_to_list): Different strategy needed here now. The list just goes into bu->obj, and we have to set up the tail to either point to the last cons cell's cdr, or else to bu->obj if the list is empty. (seq_build_init): Initialize bu->tail in the three cases that set up list collection. --- lib.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib.h') diff --git a/lib.h b/lib.h index a6e4869e..f254ce6b 100644 --- a/lib.h +++ b/lib.h @@ -471,6 +471,7 @@ struct seq_iter_ops { typedef struct seq_build { val obj; + loc tail; val self; union { val from_list_meth; -- cgit v1.2.3