Technically this is relatively simple to do as all mechanisms for that
are already in place.
Comments anyone?
Main motivation of having generators is to provide custom enumeration
facilities. Currently
for(var i in something) ...
works only for intrinsic collections like property/value lists (a.k.a
objects), arrays and indexes in persistent storages (DB)
E.g. in Sciter someone will want to write element filters
for( var paragraph in some_element.all("p") )
{
....
}
Where filter all(selector) could be something like this:
function Element.all(selector)
{
var child = this.first;
while(child)
{
if( child.match( selector ) )
yield child;
cheld = child.next;
}
}
Do you mean something close to cooperative multitasking using
generators?