At 4:32 PM +0100 7/14/05, Nicholas Clark wrote:
This is more a "note to collective 'self'" question than one I expect the
answer to right now. (The answer I expect right now is a glib "it will")
How will the perl6 compiler cope with people creating threads inside
BEGIN blocks?
Whatever the docs say, people do it in Perl 5 as soon as someone C<Use>s the
module they wrote that starts a thread in its body code. Which as I
understand it isn't considered a completely "good thing" in Perl 5 land,
because of the state of the "state" that the thread clones.
The main reason for starting threads, in my experience, is that you
want to start threads as soon as possible in Perl 5, because every
data-structure (and that includes globs holding code pointers) is
being copied to each thread. If you start a thread in BEGIN, a lot
of stuff hasn't been parsed yet, so does not need to be copied.
Assuming that Perl 6 / Parrot will be much more sane in that respect,
I personally don't think it would be a big problem to disallow
threads being started at BEGIN. On the other hand, it does seem like
a rather arbitrary decision. Would you disallow threads being
started in string evals? What else is a BEGIN block really (apart
from the time it is executed)?
Liz