1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-07 02:53:02 +00:00

Allow calling next on abstracts.

This will allow the creation of infinte
streams, low cost generators, etc.
This commit is contained in:
Calvin Rose
2020-01-18 18:09:20 -06:00
parent 51678c1aba
commit f4077b678a
10 changed files with 20 additions and 3 deletions

View File

@@ -87,6 +87,12 @@ Janet janet_next(Janet ds, Janet key) {
}
break;
}
case JANET_ABSTRACT: {
JanetAbstract abst = janet_unwrap_abstract(ds);
const JanetAbstractType *at = janet_abstract_type(abst);
if (NULL == at->next) break;
return at->next(abst, key);
}
}
return janet_wrap_nil();
}