Immediate closing of iterators
igor.bukanov at gmail.com
Thu Jan 4 05:23:24 PST 2007
On 1/4/07, Peter Hall <peterjoel at gmail.com> wrote:
> But that means a programmer wouldn't have the option to close it
> manually in that circumstance..
You mean that it would not be possible to use outside for-in loop a
generator with yield inside try with finally? Surely calling
generatorInstance.next() will throw an exception in that case but I do
not see what would prevent calling generatorInstance.close().
For me the guarantee that finally is always executed at the clear
defined moment is worth the restriction. And if some generator want to
allow its usage outside for-in, then it must not use yield with
finally and rely on the explicit close.
More information about the Es4-discuss