Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>'yield' sucks, continuations are better</p> </blockquote> <p>Actually, Python's <code>yield</code> <em>is</em> a continuation.</p> <p>What is a continuation? A continuation is saving the present point of execution with all its state, such that one can <em>continue</em> at that point later. That's precisely what Python's <code>yield</code>, and, also, precisely how it is implemented.</p> <p>It is my understanding that Python's continuations are not <em>delimited</em>, however. I don't know much about that -- I might be wrong, in fact. Nor do I know what the implications of that may be.</p> <p>Scala's continuation do not work at run-time -- in fact, there's a continuations library for Java that work by doing stuff to bytecode at run-time, which is free of the constrains that Scala's continuation have.</p> <p>Scala's continuation are entirely done at compile time, which require quite a bit of work. It also requires that the code that will be "continued" be prepared by the compiler to do so.</p> <p>And that's why for-comprehensions do not work. A statement like this:</p> <pre><code>for { x &lt;- xs } proc(x) </code></pre> <p>If translated into</p> <pre><code>xs.foreach(x =&gt; proc(x)) </code></pre> <p>Where <code>foreach</code> is a method on <code>xs</code>'s class. Unfortunately, <code>xs</code> class has been long compiled, so it cannot be modified into supporting the continuation. As a side note, that's also why Scala doesn't have <code>continue</code>.</p> <p>Aside from that, yes, this is a duplicate question, and, yes, you should find a different way to write your code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload