In general yield
is redundant in languages that have first class functions.
For example in TIScript you can do generators this way:
Generator. Note, it returns inner function.
function range( from, to )
{
var idx = from - 1;
return function() { if( ++idx <= to ) return idx; } // yields value on call
}
And its usage:
for( var item in range(12,24) )
stdout << item << " ";
for(elem in source)
in TIScript is slightly different from JS. If source is a function it gets called and its return value is assigned to the elem
until the function will not return void (default return value of empty function).