The power of Generators

Posted on by Heidy

It’s great to be done with finals! I’m particularly excited that I made all A’s again. I’m especially excited that I now have more time to work on my Research/Honors Thesis. So on this related note, this post is mainly aimed towards the research I’m involved in.

A significant portion of the Programming Language that is being developed in my research involves the use of generators. Our language uses speculative evaluation, making generators¬† a great efficient alternative to the beneficial attributes of lazy evaluation. In layman’s terms, a generator is similar to an iterative loop. It can be viewed as a function that does not return, instead it yields a specified number of values whenever instructed by the calling procedure. In a sense, a generator “returns” those values, but does not terminate. The generator process is suspended until it is called upon again by the calling procedure. Of course, there are many other ways of describing generators, specifically based on the language they are implemented in. In order to enhance my understanding of generators, last weekend I researched¬† elaborate papers and sites on generators in general. I came upon this really great site that I felt was worth sharing:

http://okmij.org/ftp/continuations/generators.html

Other than their obvious application in list comprehensions, we plan on utilizing generators in order to overcome many non-efficient attributes of Functional Languages. But hey, I won’t give spoilers away from our research! In general, generative programming has several advantages when it comes to efficient on-demand lazy sequential execution and other features that allow for speculative parallelization.

 

One comment on “The power of Generators

  1. I appreciate the power of generator expressions. It’s a pretty sweet way to efficiently express a linear computation lazily. It’s thanks entirely to Python that I’m aware of them, though I’ve also bookmarked your link for further reading.

Leave a Reply

Your email address will not be published. Required fields are marked *