5 ms·
I'm the one who wrote the post, and in retrospect I can see why people would be a bit confused at this example. I started out wanting to explain my actual impl
by PieSquared 16y ago
I'm the one who wrote the post, and in retrospect I can see why people would be a bit confused at this example.
I started out wanting to explain my actual implementation of a 'yield' command. As I wrote the post, though, it grew overcomplicated and filled with explanations of Scheme's syntax macros, which was not at all my intention.
I guess in simplifying the implementation I also lost a bit of the idea behind it. You do need continuations to implement a general-case yield; if you just want generators for a list, you can use closers (and be more efficient, too).
Thanks to you (and to parent) for pointing that out; if you don't mind, I'll add mention of what you said to the blog post?
- lmkg 16y agoBy all means, go ahead =). I'm actually a fan of continuations, I just didn't see what the purpose was in the example that you gave. What would be helpful is an explanation of why a yield with continuations is more powerful than one with closures. That will probably require an explanation of what you mean by a "general-case yield" (I'm not that familiar with Python).