Implementing "Generator" support in a custom language
        Posted  
        
            by Roger Alsing
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Roger Alsing
        
        
        
        Published on 2010-04-15T10:54:50Z
        Indexed on 
            2010/04/15
            14:23 UTC
        
        
        Read the original article
        Hit count: 410
        
I've got a bit of fettish for language design and I'm currently playing around with my own hobby language. (http://rogeralsing.com/2010/04/14/playing-with-plastic/)
One thing that really makes my mind bleed is "generators" and the "yield" keyword. I know C# uses AST transformation to transform enumerator methods into statemachines.
But how does it work in other languages? Is there any way to get generator support in a language w/o AST transformation? e.g. Does languages like Python or Ruby resort to AST transformations to solve this to?
(The question is how generators are implemented under the hood in different languages, not how to write a generator in one of them)
© Stack Overflow or respective owner