[Python-ideas] yield from multiple iterables (was Re: The async API of the future: yield-from)
Guido van Rossum
guido at python.org
Tue Oct 23 01:54:41 CEST 2012
And, predictably, that gave me a headache... :-)
--Guido van Rossum (sent from Android phone)
On Oct 22, 2012 4:49 PM, "Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote:
> Guido van Rossum wrote:
>> On Mon, Oct 22, 2012 at 3:33 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
>> It has a broader meaning than the one in Scheme; essentially
>>> it's a synonym for "callback".
>> (Off-topic:) But does that meaning apply to Scheme? If so, I wish
>> someone would have told me 15 years ago...
> It does, in the sense that a continuation appears to the
> Scheme programmer as a callable object.
> The connection goes deeper as well. There's a style of
> programming called "continuation-passing style", in which
> nothing ever returns -- every function is passed another
> function to be called with its result. In a language such
> as Scheme that supports tail calls, you can use this style
> extensively without fear of overflowing the call stack.
> You're using this style whenever you chain callbacks
> together using Futures or Deferreds. The callbacks don't
> return values; instead, each callback arranges for another
> callback to be called, passing it the result.
> This is also the way monadic I/O works in Haskell. None
> of the I/O functions ever return, they just call another
> function and pass it the result. A combination of currying
> and syntactic sugar is used to hide the fact that you're
> passing callbacks -- aka continuations -- around all
> over the place.
> Now, it turns out that you can define all the semantics
> of Scheme, including its continuations, by writing a Scheme
> interpreter in Scheme that doesn't itself use Scheme
> continuations. You do it by writing the whole interpereter
> in continuation-passing style, and it becomes clear that
> at that level, the "continuations" are just ordinary
> functions, relying on lexical scoping to capture all of the
> necessary state.
> I guess that was just Steve showing off. :-)
> Not really -- to someone with a Scheme or FP background,
> it's near-impossible to look at something like a chain
> of Deferred callbacks without the word "continuation"
> springing to mind. I agree that it's not helpful to
> anyone without such a background, however.
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas