summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/lib.c b/lib.c
index ed0a47fe..1e127e88 100644
--- a/lib.c
+++ b/lib.c
@@ -1287,6 +1287,8 @@ static val iter_dynamic(struct seq_iter *si_orig)
val iter_more(val iter)
{
+ val self = lit("iter-more");
+
switch (type(iter)) {
case NIL:
return nil;
@@ -1295,6 +1297,8 @@ val iter_more(val iter)
case NUM:
case BGNUM:
case FLNUM:
+ case CONS:
+ case LCONS:
return t;
case COBJ:
if (iter->co.cls == seq_iter_cls)
@@ -1307,15 +1311,19 @@ val iter_more(val iter)
val iter_more_meth = get_special_slot(iter, iter_more_m);
if (iter_more_meth)
return funcall1(iter_more_meth, iter);
+ return t; /* needed for supporting fast procotol */
}
- /* fallthrough */
default:
- return t;
+ break;
}
+
+ unsup_obj(self, iter);
}
val iter_item(val iter)
{
+ val self = lit("iter-item");
+
switch (type(iter)) {
case NIL:
return nil;
@@ -1324,6 +1332,9 @@ val iter_item(val iter)
case BGNUM:
case FLNUM:
return iter;
+ case CONS:
+ case LCONS:
+ return car(iter);
case COBJ:
if (iter->co.cls == seq_iter_cls)
{
@@ -1338,8 +1349,10 @@ val iter_item(val iter)
}
/* fallthrough */
default:
- return car(iter);
+ break;
}
+
+ unsup_obj(self, iter);
}
val iter_step(val iter)
@@ -1359,7 +1372,8 @@ val iter_step(val iter)
{
val next = cdr(iter);
if (next && !consp(next))
- uw_throwf(type_error_s, lit("~a: ~s is not a cons"), self, next, nao);
+ uw_throwf(type_error_s, lit("~a: ~s is improperly terminated"),
+ self, iter, nao);
return next;
}
case COBJ:
@@ -1379,17 +1393,10 @@ val iter_step(val iter)
}
/* fallthrough */
default:
- {
- val next = cdr(iter);
- if (next) {
- seq_info_t sinf = seq_info(next);
- if (sinf.kind != SEQ_LISTLIKE)
- uw_throwf(type_error_s, lit("~a: ~s is improperly terminated"),
- self, iter, nao);
- }
- return next;
- }
+ break;
}
+
+ unsup_obj(self, iter);
}
val iter_reset(val iter, val obj)