Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl 6 coroutines (RFC 31)

by Abigail (Deacon)
on Jul 13, 2001 at 18:38 UTC ( #96413=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: Perl 6 coroutines (RFC 31)
in thread Perl 6 coroutines (RFC 31)

My issue with the proposal is that the iterator would be global for all instances. It would be like each maintaining a single global state, rather than per-hash.
Ah, but not if you create your iterators as anonymous closures! Then you can have several instances, each working on separate data, and each keeping state.

but more to the point, coroutine like behaviour only happens when yield is used. In the example you present, no yield happens, so it will behave like any other subroutine
Why do you say that? next_inorder() yeilds.
I was referring to your:

Say I'm iterating over a collection and break out of the loop when I find the element I want. Just last it, and don't look at the rest.
No yield here.

-- Abigail


Comment on Re: Perl 6 coroutines (RFC 31)
Download Code
Re: Re: Perl 6 coroutines (RFC 31)
by John M. Dlugosz (Monsignor) on Jul 13, 2001 at 18:56 UTC
    I see... I thought about wrapping the iterator in a closure, but that won't help. It would work if yeild was called from the closure's block (not from a reusable helper function).

    My example means that my loop is calling next_inorder() to loop. It does not wait for next_inorder() to return undef, but breaks out of the loop when it sees the element it's looking for. next_inorder yields. Caller want's to quit early. Get it?

    —John

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://96413]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-08-23 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls