From 16397fbdedaa4510bf17b4a27cb67ecb1ee0a3c2 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 6 Jun 2016 06:32:19 -0700 Subject: Handle structs in list collection operations. This eliminates the error which occurs when a sequence implemented as a struct is nconced or appended onto. The struct is converted to a list, and so is the object on the right hand side. As a result, more generic sequence code works on structs. * lib.c (list_collect_nconc, list_collect_append): Handle tail of type COBJ by converting to a list, storing that list back in the tail and then destructively tacking onto that the obj operand, also turned into a list. --- lib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib.c') diff --git a/lib.c b/lib.c index 8807a189..c734324b 100644 --- a/lib.c +++ b/lib.c @@ -803,6 +803,11 @@ loc list_collect_nconc(loc ptail, val obj) case LSTR: replace_str(tailobj, obj, t, t); return ptail; + case COBJ: + set(ptail, tolist(tailobj)); + ptail = tail(deref(ptail)); + set(ptail, tolist(obj)); + return ptail; default: uw_throwf(error_s, lit("cannot nconc ~s to ~s"), obj, tailobj, nao); } @@ -833,6 +838,11 @@ loc list_collect_append(loc ptail, val obj) set(ptail, copy_str(tailobj)); replace_str(deref(ptail), obj, t, t); return ptail; + case COBJ: + set(ptail, tolist(tailobj)); + ptail = tail(deref(ptail)); + set(ptail, tolist(obj)); + return ptail; default: uw_throwf(error_s, lit("cannot append to ~s"), tailobj, nao); } -- cgit v1.2.3