develooper Front page | perl.ithreads | Postings from December 2007

Re: Lexical Object copied to new thread

Thread Previous | Thread Next
Dave Mitchell
December 23, 2007 14:16
Re: Lexical Object copied to new thread
Message ID:
On Sun, Dec 23, 2007 at 11:59:21PM +0200, Shmuel Fomberg wrote:
> Hi Dave.
> >> Anyway, my question is that $x is a lexical inside run_test, and as much
> >>as
> >> I understood it was not suppose to be copied to the new thread. But it
> >is.
> >In a new thread, *everything* is copied, apart from the calling stacks.
> Well, It seen that the calling stack is copied too. But it kept frozen until
> the thread is destroyed, and then Perl destroy the calling stack frame by
> frame. 

Um no, lexical variables aren't stored on the call stack. The stack isn't
copied (so caller() in a thread won't show any history outside the thread
itself), but all lexicals are cloned.

But Pity stayed his hand. "It's a pity I've run out of bullets",
he thought. -- "Bored of the Rings"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About