Hi, Luke Palmer wrote: > On 7/14/05, Nicholas Clark <[EMAIL PROTECTED]> 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? > > A glib "it won't". > > Unless someone can come up with a reason you would want to do that.
class SomeCryptMod { my %tables_which_are_expensive_to_create = precalc_tables(); # called at BEGIN time sub precalc_tables () { # Use threads to speed up calculation: for 0..10000 -> $i { # Or whatever the thread API is. Thread.create:{ precalc_table_for $i }; } Thread.wait_for_all_threads; } ...; } If you compile that module then, the compiler will only have to calculate %tables_which_are_expensive_to_create once (as the results are serialized in the .pbc), and the code could use threads to speed up calculation. (But I'm fine with outlawing it, or making it a new feature in Perl 6.x.y, or whatever :)) --Ingo -- Linux, the choice of a GNU | self-reference, n. - See self-reference generation on a dual AMD | Athlon! |