summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-07 16:30:06 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-07 16:30:06 -0800
commit01b5b93cdf4cfb0ba14178f22eb0b1143ef5704f (patch)
tree444ebb37fce80e76df1f2e663996b7fdb71d1de7 /lib.c
parent79781ded91b29fbdc406d460e466c5ffb06a1454 (diff)
downloadtxr-01b5b93cdf4cfb0ba14178f22eb0b1143ef5704f.tar.gz
txr-01b5b93cdf4cfb0ba14178f22eb0b1143ef5704f.tar.bz2
txr-01b5b93cdf4cfb0ba14178f22eb0b1143ef5704f.zip
* debug.c (debug): Fix regression: repeat last command by hitting
Enter stopped working. This was broken by recent bugfixes in the string splitting functions, which introduced a semantics change. * eval.c (flip_s, vecref_s): New symbol variables. (op_modplace): New places (vecref ...) and (flip ...). Bugfix: dec operator was incrementing. (expand_place): Handle vecref and flip. Bugfix: pop has no third argument and so is now handled by the same case as flip. Bugfix: if a modify form has no third argument, then do not resynthesize it with a nil third argument. (eval_init): Initialize new symbol variables. Register new flip operator. Register new list_vectory function as intrinsic. * lib.c (rplacd): When modifying the cdr field of a lazy cons, then lapse the lazy function to nil! This is needed by user-defined lazy conses, and it makes sense to do it this way rather than put in some explicit interface. (list_vector): New function. * lib.h (list_vector): Declared.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index be23f012..96b0e3c6 100644
--- a/lib.c
+++ b/lib.c
@@ -222,13 +222,14 @@ val rplaca(val cons, val new_car)
}
-val rplacd(val cons, val new_car)
+val rplacd(val cons, val new_cdr)
{
switch (type(cons)) {
case CONS:
- return cons->c.cdr = new_car;
+ return cons->c.cdr = new_cdr;
case LCONS:
- return cons->lc.cdr = new_car;
+ cons->lc.func = nil;
+ return cons->lc.cdr = new_cdr;
default:
type_mismatch(lit("~s is not a cons"), cons, nao);
}
@@ -2408,6 +2409,21 @@ val vector_list(val list)
return vec;
}
+val list_vector(val vec)
+{
+ list_collect_decl (list, ptail);
+ int i, len;
+
+ type_check(vec, VEC);
+
+ len = c_num(vec->v.vec[vec_fill]);
+
+ for (i = 0; i < len; i++)
+ list_collect(ptail, vec->v.vec[i]);
+
+ return list;
+}
+
static val lazy_stream_func(val env, val lcons)
{
val stream = car(env);