Does Factor have anything akin to the generators in the ICON language?

Generators are useful for recursive-descent searches. They aren't necessary; 
it is possible to write these kinds of programs without generators (I did 
one such program in IBM370 assembly-language). When you do without 
generators, you have both the code that generates the datums, and the code 
that tests the datums, and the recursive call (in the event of failure of 
the test), all together in one big complicated function. With generators, 
you can factor the code into separate functions that can be tested in 
isolation. As factoring is what Factor is all about, I would hope for 
generators, but I couldn't find anything in the documentation. If they are 
there, can anybody point me toward them?

Generators are not something that I can write myself, as they require the 
function to store its internal state ("suspend" itself, in ICON terminology) 
somewhere --- then, the next time that it is called, it reanimates itself 
from this suspended state rather than start from the beginning again. To 
code this, I would have to know more about the internal workings of Factor 
functions than I do. I might be able to write something like this in Forth 
using CATCH and THROW, but I'm not sure about that without having tried it.

BTW, I have read about Python's generators, and they seem comparable to 
ICON's, but haven't tried them out. Do any other languages have generators? 
I have read that Prolog has something similar, but I don't know the first 
thing about Prolog. Both ICON and Prolog seem to have largely disappeared; I 
never hear anything about them anymore.


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to