gnperumal / py2scala

Automatically exported from code.google.com/p/py2scala
0 stars 0 forks source link

Convert Python generators #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is an Improvement Request or Feature Request, if you will.

Python generators are amazing for certain kinds of applications, in particular 
those which involve some sort of delay for every chunk of information, like 
typically applications consuming data from the web or other resources from the 
network.

Scala continuations is the closest thing to Python generators.
Unfortunately, Scala continuations require a lot of boilerplate to be a viable 
solution. This article in SO explains how Python generators can be replaced by 
Scala continuations:
   http://stackoverflow.com/questions/7303166/preferred-way-to-implement-yield-in-scala/11277282#11277282

Notice that Scala continuations are substantially different from Python 
generators, which means that not all converted code will work as expected or 
even compile, I guess.

Original issue reported on code.google.com by rgomes.i...@gmail.com on 21 Nov 2013 at 5:16

GoogleCodeExporter commented 9 years ago
I also found this: http://notes.langdale.com.au/Generators_in_Scala.html

Original comment by rgomes.i...@gmail.com on 21 Nov 2013 at 5:18