diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | lib.c | 14 |
2 files changed, 20 insertions, 2 deletions
@@ -1,5 +1,13 @@ 2015-05-11 Kaz Kylheku <kaz@kylheku.com> + Handle vectors and strings in rplaca and rplacd. + + * lib.c (rplaca, rplacd): Use refset and replace + respectively to handle vectors and strings. + Adjust type mismatch error message. + +2015-05-11 Kaz Kylheku <kaz@kylheku.com> + * lib.c (chr_str_set): Check for literal strings. 2015-05-11 Kaz Kylheku <kaz@kylheku.com> @@ -283,8 +283,13 @@ val rplaca(val cons, val new_car) case LCONS: set(mkloc(cons->lc.car, cons), new_car); return cons; + case VEC: + case STR: + case LSTR: + refset(cons, zero, new_car); + return cons; default: - type_mismatch(lit("~s is not a cons"), cons, nao); + type_mismatch(lit("rplaca: cannot modify ~s"), cons, nao); } } @@ -297,8 +302,13 @@ val rplacd(val cons, val new_cdr) case LCONS: set(mkloc(cons->lc.cdr, cons), new_cdr); return cons; + case VEC: + case STR: + case LSTR: + replace(cons, new_cdr, one, t); + return cons; default: - type_mismatch(lit("~s is not a cons"), cons, nao); + type_mismatch(lit("rplacd: cannot modify ~s"), cons, nao); } } |