summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-14 14:43:03 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-14 14:43:03 -0800
commit311294aef85c349ee71c3925a52d0888073a1fa0 (patch)
treec1fb738b283405460d30abb9dd3ab759f32501b6 /lib.c
parent1f2f893c7de22ef3f64d68e0b62d43fbdb07af7c (diff)
downloadtxr-311294aef85c349ee71c3925a52d0888073a1fa0.tar.gz
txr-311294aef85c349ee71c3925a52d0888073a1fa0.tar.bz2
txr-311294aef85c349ee71c3925a52d0888073a1fa0.zip
* lib.c (car, cdr): Semantics fix for lazy conses.
Ignore the return value of the lazy cons function: do not return nil if the function returns nil. This useless behavior was a source of inconvenience in lazy cons programming, requiring the lazy function to return non-nil in addition to installing the car and cdr fields.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib.c b/lib.c
index 64cf66eb..575465e7 100644
--- a/lib.c
+++ b/lib.c
@@ -183,8 +183,7 @@ val car(val cons)
if (cons->lc.func == nil) {
return cons->lc.car;
} else {
- if (!funcall1(cons->lc.func, cons))
- return nil;
+ funcall1(cons->lc.func, cons);
return cons->lc.car;
}
default:
@@ -203,8 +202,7 @@ val cdr(val cons)
if (cons->lc.func == nil) {
return cons->lc.cdr;
} else {
- if (!funcall1(cons->lc.func, cons))
- return nil;
+ funcall1(cons->lc.func, cons);
return cons->lc.cdr;
}
default: