* yary <not....@gmail.com> [2015-12-09 19:40]:
> Being able to explicitly return a final value from a generator is
> a handy ability to have. This is because it enables for a final value
> to be returned by a generator (from perhaps some form of coroutine
> computation) that can be specifically handled by the client code
> executing the generator. This is far simpler than forcing the client
> code to firstly check whether the final value has been yielded, and
> then if so, to handle that value specifically.

But conversely it forces the client code to handle the final value in
a way that is unlike all of the other values. So it is at least both
simpler and less simple.

What makes the final value so special anyhow? (I can’t think of any good
reasons, only bad ones – e.g. you have a narrow idea of the purpose of
generators, or you wish you could sometimes call a generator as a normal
function, etc.) Do they have any examples of where this helps?

Aristotle Pagaltzis // <http://plasmasturm.org/>

Reply via email to