develooper Front page | perl.perl5.porters | Postings from April 2007

Re: Differences between state variables and smart matches in 5.10 and 6

Thread Previous
From:
Rafael Garcia-Suarez
Date:
April 2, 2007 05:47
Subject:
Re: Differences between state variables and smart matches in 5.10 and 6
Message ID:
b77c1dce0704020547w346f7299n88622daaae7af4b7@mail.gmail.com
On 02/04/07, Elizabeth Mattijsen <liz@dijkmat.nl> wrote:
>
> Hmmm... if run before a thread starts, it will inherit.  If not run
> before a thread starts, it will run once inside the thread.
> Different threads may get different initializations.  What is wrong
> with that?

Nothing at all. That's what happens with state variables outside of
closures now. Starting a thread clones the pad that holds lexicals.

> >START blocks (not ONCE, after verification in Synopsis 4) run once per
> >closure. See t/op/state.t for an example of code with a state variable
> >in a closure, that gets its own state at each closure generation.
>
> Ah, that's a different kettle of fish...  ;-)  Thanks for the clarification...

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About