diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-06-06 06:32:19 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-06-06 06:32:19 -0700 |
commit | 5dffff93f936726ec2736c5c0525883ea08b7c92 (patch) | |
tree | 267fadde5128711d9255116fb18b6a46a43d2f86 /lib.c | |
parent | a8b541ee2191ac07ccb45297e5d07b8e91a0a4b7 (diff) | |
download | txr-5dffff93f936726ec2736c5c0525883ea08b7c92.tar.gz txr-5dffff93f936726ec2736c5c0525883ea08b7c92.tar.bz2 txr-5dffff93f936726ec2736c5c0525883ea08b7c92.zip |
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.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); } |