diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-05-11 07:51:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-05-11 07:51:56 -0700 |
commit | 6a48e98582b4b8025156fe0dc467a45b17dd4f7a (patch) | |
tree | a72a1d998eb2f9b0941c08ac6a0f04adbab51030 | |
parent | fd3f41e01856e41bb6e35b139066b2e96d01f7a3 (diff) | |
download | txr-6a48e98582b4b8025156fe0dc467a45b17dd4f7a.tar.gz txr-6a48e98582b4b8025156fe0dc467a45b17dd4f7a.tar.bz2 txr-6a48e98582b4b8025156fe0dc467a45b17dd4f7a.zip |
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.
-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); } } |