From 311294aef85c349ee71c3925a52d0888073a1fa0 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 14 Dec 2011 14:43:03 -0800 Subject: * 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. --- ChangeLog | 9 +++++++++ lib.c | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8caaf6a6..1dfaffb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-12-14 Kaz Kylheku + + * 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. + 2011-12-14 Kaz Kylheku * arith.c (abso): broken for fixnums. 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: -- cgit v1.2.3